You are on page 1of 65

Definition

 An operating system is a program that acts as an interface

between the user and the computer hardware and

controls the execution of all kinds of programs.


 When two or more programs are residing in memory at the
same time, then sharing the processor is referred to the
multiprogramming. Multiprogramming assumes a single
shared processor. Multiprogramming increases CPU utilization
by organizing jobs so that the CPU always has one to execute.

 Following figure shows the memory layout for a


multiprogramming system.
 Advantages of Multiprogramming
The characteristics of uniprogramming are as follows:

 Uni-programming allows only one program to be


present in memory at a time.

 The resources are provided to the single program that


is present in the memory at that time.

 Since only one program is loaded the size is small as


well.
 Linux is introduced by Linus Torvalds, a student in Finland.

What is Linux?

 Linux is a free, open source operating system kernel, but now is


considered to be packaged with other programs to be an entire
operating system (known as a distribution, as there are different
ones). It is similar to the Unix operating system which has been
around for decades.

 Red Hat and Ubuntu are two examples of Linux distributions

 two most popular distributions are Ubuntu and Fedora.


 the mid-1960s time-sharing operating system called MULTICS
(Multiplexed Information and Computer Services)

 UNICS (UNiplexed Information and Computing Service)

 By the end of 1971UNIX (written in all-caps, but not an acronym).

 Unix is a family of multitasking, multiuser operating systems that


derive from the original AT&T Unix, developed in the 1970s at
the Bell Labs research center by Ken Thompson, Dennis Ritchie, and
others.

 In the 1990s, Unix-like systems grew in popularity as Linux and BSD


distributions were developed through collaboration by a worldwide
network of programmers.

 In 2000, Apple released Darwin that became the core of the OS


X operating system
 Today more than 97 % of the world's
supercomputers (including the complete top 10),
more than 80 % of all smart phones, many
millions of desktop computers, around 70%
percent of all web servers, a large chunk of
tablet computers, and several appliances (dvd
players, washing machines, dsl modems, routers,
self-driving cars, space station laptops...) run
Linux.
 Linux is by far the most commonly used
operating system in the world.
Linux Operating System has primarily three components
Kernel - Kernel is the core part of Linux.
 It is responsible for all major activities of this operating system.
 It is consists of various modules and it interacts directly with the
underlying hardware.
 Kernel provides the required abstraction to hide low level hardware
details to system or application programs.
System Library
 System libraries are special functions or programs using which
application programs or system utilities accesses Kernel's features.
 These libraries implements most of the functionalities of the
operating system and do not requires kernel module's code access
rights.
 System Utility - System Utility programs are responsible
to do specialized, individual level tasks.
Document formatting
 Unix systems were used from the outset for
document preparation and typesetting systems, and
included many related programs such as nroff,
troff, tbl, eqn, refer, and pic. Some modern Unix
systems also include packages such as TeX and
Ghostscript.
 Graphics – the plot subsystem provided facilities for
producing simple vector plots in a device-
independent format, with device-specific
interpreters to display such files. Modern Unix
systems also generally include X11 as a standard
 Commands
 Unix makes little distinction between
 commands (user-level programs) for system operation and maintenance (e.g.
cron),

 commands of general utility (e.g. grep),

 more general-purpose applications such as the text formatting and typesetting


package.

some major categories are:

 sh – the "shell" programmable command-line interpreter, the


primary user interface on Unix before window systems appeared,
and even afterward (within a "command window").

 Utilities – the core toolkit of the Unix command set, including cp,
ls, grep, find and many others. Subcategories include:
 System utilities – administrative tools such as mkfs, fsck, and many others.

 User utilities – environment management tools such as passwd, kill, and


 Communications – early Unix systems contained no inter-system
communication, but did include the inter-user communication
programs mail and write. V7 introduced the early inter-system
communication system UUCP, and systems beginning with BSD
release 4.1c included TCP/IP utilities.

 Documentation – Unix was the first operating system to include all


of its documentation online in machine-readable form. The
documentation included:
 man – manual pages for each command, library component, system
call, header file, etc.

 doc – longer documents detailing major subsystems, such as the C


language and troff
Kernel Mode
 Kernel component code executes in a special privileged
mode called kernel mode with full access to all resources
of the computer. This code represents a single process,
executes in single address space and do not require any
context switch and hence is very efficient and fast.
User Mode
 User programs and other system programs works in User
Mode which has no access to system hardware and kernel
code.
Following are some of the important features of
Linux Operating System.
 Portable

 Open Source

 Multi-User

 Multiprogramming

 Hierarchical File System

 Shell

 Security

 Communication
 Unix is a highly portable OS.
 It can be ported to a variety of hardware
platforms.
 It is the only system which has been ported
across various hardware platforms of major
vendors such as IBM, DEC, HP and SUN.
 Most OSs are written for one specific machine
or platform only.
 Linux source code is freely available and it is
community based development project.

 Multiple teams work in collaboration to


enhance the capability of Linux operating
system and it is continuously evolving.
 Usage
 The freedom to run the program, for any purpose.
 The freedom to study how the program works, and
change it to make it do what you wish.
 The freedom to redistribute copies so you can help your
neighbor.
 The freedom to distribute copies of your modified
versions to others.
 GUI
 Cost
 Threat Detection and Solution
 Development and Distribution
 Security
 Dynamic nature
 Linux in World Wide Web
 Understanding
 Compatibility
 Sometimes you can find third party applications, sometimes you
can’t
 Alternative Programs
 there are still some applications that exist on Windows that
have no equivalent Linux Application.
 First, it’s more difficult to find applications to support your
needs.
 One main issue with Linux is drivers.
 Support for open-source can also be an issue
 Before you decide on open-source technology, make sure you have
the resources and personnel to support the software.
 Unixhas 3 inherent provisions for protecting
data.
 Assign passwords and login name to users area.

 Provide read, write and execute permission to


each file.

 Encrypt files into an unreadable format, and


decrypting the file is also possible.
 Linux provides a standard file structure in which
system files/ user files are arranged.

SHELL

 Linux provides a special interpreter program


which can be used to execute commands of the
operating system.

 It can be used to do various types of operations,


call application programs. etc.
 The communication may be within the network of a
single main computer or between two or more
such computer networks.

 The users can


easily exchange mail, data programs through
such networks.

 Distance posses no barrier to


passing information or messages to and fro.
Linux System Architecture is consists of following layers

 Hardware layer - Hardware consists of all peripheral


devices (RAM/ HDD/ CPU etc).

 Kernel - Core component of Operating System, interacts


directly with hardware, provides low level services to
upper layer components.

 Shell - An interface to kernel, hiding complexity of kernel's


functions from users. Takes commands from user and
executes kernel's functions.

 Utilities - Utility programs giving user most of the


functionalities of an operating systems.
 Kernel is heart of Linux OS. It manages resource of
Linux Os. For e.g. Facility to store data, print data on
printer, memory, file management etc .

 Kernel decides who will use this resource, for how long
and when. It runs your programs (or set up to execute
binary files).

 The kernel acts as an intermediary between the


computer hardware and various
programs/application/shell.
It's Memory resident portion of Linux. It
performance following task :-
 I/O management
 Process management
 Device management
 File management
 Memory management
 Shell accepts your instruction or commands in
English (mostly) and if its a valid command, it is pass
to kernel.

 Shell is a user program or it's environment provided


for user interaction. Shell is an command language
interpreter that executes commands read from the
standard input device (keyboard) or from a file.

 Shell is not part of system kernel, but uses the


system kernel to execute programs, create files etc.
Shell Name Developed by Where Remark
BASH ( Bourne- Brian Fox and Chet Free Software Most common shell
Again SHell ) Ramey Foundation in Linux. It's
Freeware shell.
CSH (C SHell) Bill Joy University of The C shell's
California (For syntax and usage
BSD) are very similar to
the C programming
language.

KSH (Korn SHell) David Korn AT & T Bell Labs --


TCSH See the man page. -- TCSH is an
Type $ man tcsh enhanced but
completely
compatible version
of the Berkeley
UNIX C shell
(CSH).
 Bourne Shell (sh) – Bourne Shell is the original unix shell
developed at AT&T by Stephen Bourne. Bourne shell also named
as (sh) programming name. It used the symbol $. Bourne shell’s
family is bourne, korn shells, bash and zsh .

 korn shell (ksh) – korn shell is the unix shell developed by David
korn of Bell labs. Is is considered as the family member of
Bourne shell as it uses the $ symbol of Bourne shell. It is also
names as ksh programmatic ally and it most widely used shell.

 Bourne Again Shell (bash) – It is the free version of Bourne shell


and comes with all UNIX/Linux systems as free with some
additional features like command line editing. Its program name
is bash. It can read commands from file called scripts.
Like all Unix shells it supports the following:

 File name wildcarding

 Piping

 Hear documents

 Command execution

 Variables and control structures for condition testing and iteration

 C Shell (sh) – C shell is the UNIX shell created by Bill joy at California
university as an alternative to Bourne shell – Unix original shell. C
shell along with Bourne and Korn, are there most popular and
commonly used shells. csh is the program name for C shell.

 Tab C chell (tcsh) – It is the family member of C shell with


additional features like enhanced history substitution to reuse
commands, spelling correction and word completion.
 need to know both your username and your
password to log into a UNIX system.
 For example the wants to log into the college
computer system, he types:
 login: rama
 password: ayodhya
 The username is an identifier: it tells the
computer who you are. The password is an
authenticator
 cal - Displays a calendar
 date - print or set the system date and time
 bc - An arbitrary precision calculator language
 echo - Display a line of text.
 passwd - update user's authentication tokens
 who - Show who is logged on
 w - Show who is logged on and what they are
doing
 uname - Print system information
 expr - Evaluate expressions
 rev - reverse lines of a file or files
 man-on-line manual page command for help
 Cal Displays a calendar
 Syntax

 cal [−smjy13] [[[day] month]


year]Description
View calendar of specific month or year
Options
-1 Display single month output. (This is the default.)
−3 Display prev/current/next month output.
−s Display Sunday as the first day of the week.
−m Display Monday as the first day of the week.
−j Display Julian dates (days one-based, numbered from January 1).
−y Display a calendar for the current year.
−V Display version information and exit.
$ cal
 cal, when used without an argument, prints
calendar of current month
$ cal 2000
 To view the calendar of a specific year,
provide the year as an argument
 date: displays the current date
Usage:
$ date
Output:
Tue Apr 21 21:33:49 IST 2009
user$ date +"%D %H:%M:%S"
04/21/09 21:35:02
Options:
d - The day of the month (1-31)
y - The last two digits of the year
H,M,S - Hour Minute and second respectively
D - the date in mm/dd/yy
the Linux file system is organized as a hierarchy
 All of the files in the UNIX file system are organized into a
multi-leveled hierarchy called a directory tree.

 A family tree is an example of a hierarchical structure that


represents how the UNIX file system is organized. The UNIX file
system might also be envisioned as an inverted tree or the root
system of plant.

 At the very top of the file system is single directory called "root"
which is represented by a / (slash). All other files are
"descendents" of root.

 The number of levels is largely arbitrary, although most UNIX


systems share some organizational similarities. The "standard"
UNIX file system is discussed later.
 The UNIX file system contains several different
types of files:
Ordinary Files
 Used to store your information, such as some text you
have written or an image you have drawn. This is the
type of file that you usually work with.

 Always located within/under a directory file

 Do not contain other files


Directories
 Branching points in the hierarchical tree

 Used to organize groups of files

 May contain ordinary files, special files or other


directories

 Never contain "real" information which you would work


with (such as text). Basically, just used for organizing
files.

 All files are descendants of the root directory, ( named


/ ) located at the top of the tree.
Special Files
 Used to represent a real physical device such as a
printer, tape drive or terminal, used for Input/Ouput
(I/O) operations
 Unix considers any device attached to the system to
be a file - including your terminal:
 By default, a command treats your terminal as the
standard input file (stdin) from which to read its input
 Your terminal is also treated as the standard output file
(stdout) to which a command's output is sent
 Stdin and stdout will be discussed in more detail later

 Two types of I/O: character and block


 Usually only found under directories named /dev
File Names

 UNIX permits file names to use most characters, but avoid spaces, tabs and
characters that have a special meaning to the shell, such as:

&;()|?\'"`[]{}<>$-!/

 Case Sensitivity: uppercase and lowercase are not the same! These are three
different files:

NOVEMBER November november

 Length: can be up to 256 characters

 Extensions: may be used to identify types of files

 libc.a - archive, library file

 program.c - C language source file

 alpha2.f - Fortran source file

 xwd2ps.o - Object/executable code

 mygames.Z - Compressed file

 Hidden Files: have names that begin with a dot (.) For example:
 Uniqueness: as children in a family, no two files with

the same parent directory can have the same name.

Files located in separate directories can have identical

names.

 Reserved Filenames:

 / - the root directory (slash)

 . - current directory (period)

 .. - parent directory (double period)

 ~ - your home directory (tilde)


Pathnames

 Specify where a file is located in the hierarchically


organized file system

 Must know how to use pathnames to navigate the UNIX


file system

Types of Pathname

 Absolute Pathname: tells how to reach a file begining


from the root; always begins with / (slash). For example:
 /usr/local/doc/training/sample.f

 Relative Pathname: tells how to reach a file from the


directory you are currently in ( current or working
directory); never begins with / (slash). For example:
 For example, if your current directory is

/usr/home/johnson and you wanted to change to


the directory /usr/home/quattro, you could use
either of these commands:

 cd ../quattro - relative pathname

 cd /usr/home/quattro - absolute pathname


 pwd
 /home/ryan
Relative path
 ls Documents
 file1.txt file2.txt file3.txt
 ...
 ls /home/ryan/Documents
 file1.txt file2.txt file3.txt
 ...

Absolute path
~ (tilde) - This is a shortcut for your home directory.
eg, ~/Documents
. (dot) - This is a reference to your current
directory. Eg ./Documents
 .. (dot dot)- This is a reference to the parent
directory.
 eg if you were in the path /home/ryan you could run the
command ls ../../ and this would do a listing of the root
directory.
 cd .. – change your directory to the parent of the
current directory.
 cd ../.. – it moves one level up
 cd – change directory
 pwd – present working directory
 mkdir – make directory
 rmdir – remove directory
• When you log into the system, UNIX places you in a
directory called home( or login directory)

• It is created by the system when a user account is


opened.

• Home directory is decided by the system


administrator at the time of opening an user account
& is stored in the file /etc/passwd

• echo $HOME – shell variable knows home directory

/home/13ucsa501
Linux directories
• /bin— Contains common Linux user commands, such as ls, sort, date, and
chmod.

• /boot— Has the bootable Linux kernel and boot loader configuration files
(GRUB).

• /dev — Contains files representing access points to devices on your


systems. (ram*),

• /etc — Contains administrative configuration files.

• /home — Contains directories assigned to each user with a login account.

• /media — Provides a location for mounting devices, such as remote file


systems and removable media (with directory names of cdrom, floppy,
and so on

• /proc — Provides a mechanism for the kernel to send information to


processes.

• /root — Represents the root user’s home directory.


• /sys ⎯ contain files for getting hardware status and
reflecting the system's device tree

• /tmp — Contains temporary files used by applications.

• /usr — Contains user documentation, games, graphical


files (X11), libraries (lib), and a variety of other user
and administrative commands and files.

• /var — Contains directories of data used by various


applications.
 Directory commands - cd, mkdir, rmdir, pwd.
 File command - Creating and viewing files using
cat.
 Wildcards for file name matching *,?,[]. , cp,
rm, mv, ln
 cat: displaying text files only
 cat > file: create file. <ctrl-d> to terminate
 cat file1 file2 – more than one filename as
arguments – the content of the second file
are shown immediately after the first file.
 cd:changing directories
 mkdir: making directories
 mkdir patch dbs doc: Multiple directories
 mkdir pis pis/progs pis/data: directory tree
 rmdir: removing directories (rd – Linux)
 rmdir pis/progs pis/data: del many dir’s
 pwd: present working directory
 ls: listing files (next page)
 ls –x <dirname>: listing directory contents
 [lakshmi@linuxserver ~]$pwd
 [lakshmi@linuxserver ~]$mkdir test
 [lakshmi@linuxserver ~]$cd test
 [lakshmi@linuxserver test]$ pwd
 [lakshmi@linuxserver test]$ cat>chap01
Dfjkajd
asldk
<ctrl-d>
 [lakshmi@linuxserver test]$ ls
 [lakshmi@linuxserver test]$ cd
 [lakshmi@linuxserver ~]$ Pwd
 [lakshmi@linuxserver ~]$ Rmdir test
Option Description
-x Displays multi-columnar output
-F Marks executables with a * and directories with
a/
-r Sorts files in reverse order
-a Shows all files including ., ..
-R Recursive listing of all files in sub-directories
-l Long list
-d Forces listing of directories
-t Sorts file by modification time
-u Sorts files by access time (when used with t)
-i Shows inode number of a file
 cat: displaying files

 cat > foo: create file. <ctrl-d> to terminate

 cp: copying file


 cp chap01 progs
 cp chap01 chap02 chap03 test
 cp –i chap01 chap02: prompts before
overwriting
• cp – copy a file or a group of files.

• cp file1 file3 (file3 – destination file)

• cp chap01 progs/unit1 #chap01 copied to unit1 under progs

• cp chap01 progs #chap01 retains its name under progs

• cp /home/bca501/.prof .prof #destination is a file

• cp /home/bca501/.prof . #destination is the current directory

• cp chap01 chap02 chap03 progs

• cp chap* progs # * short-hand for multiple filenames

• copying directory structures (-r)

cp –r progs newprogs

• Interactive copying (-i)

cp –I chap01 unit1

cp: overwrite unit1? y


 cp –r progs newprogs: copy dir structure
 rm: delete file
 rm chap01 chap02 chap03: multiple files
 rm chap*
 rm *: all files in dir deleted
 rm –i chap01 chap02 chap03: interactive deletion
 rm –r *: recursive deletion
 rm –rf *: deletes even write protected files
 mv: renaming files and directories
 mv chap01 chap02 chap03 progs: moves files to progs dir
 ln: Links (same file with more than one name)
 ln emp.lst employee
 ls –li emp.lst employee: Used to show that both files have
same inode
 A wildcard is a character that can stand for all
members of some class of characters. When you use a
wildcard the computer systems substitutes the
members of the class for the wildcard character
 Special characters, or metacharacters, have a special
meaning to the shell. They can be used as wildcards
to specify the name of a file without having to type
out the file's full name. Some of the most commonly
used metacharacters are "*", "?", "[]", and "-".
 *: matches any number of characters (including
none)
 ls chap*

 ?: matches a single character


 ls chap?
 ls chap??

[ ]: character class
 ls –x chap0[1-4]
 ls –x chap0[124]

 !: negating the character class


 ls chap0[!3]

You might also like