Date post: | 28-Feb-2018 |
Category: |
Documents |
Upload: | divyarai12345 |
View: | 225 times |
Download: | 0 times |
of 25
7/25/2019 Operating Systems and Linux II
1/25
Operating Systems and Linux
Partha Sarathi Dasgupta
MIS GroupIndian Institute of Management Calcutta
7/25/2019 Operating Systems and Linux II
2/25
Partitions
Major partitions on a Linux system:data partition
: normal Linux system data, including the root partitioncontaining allthe data to start up and run the system
swap partition: expansion of the computer's physical memory, extra memory on harddisk
!sually, systems contain a root partition, one or more data partitions and one or more
s"ap partitions
fdisk
#"ap space is only accessi$le for the system itself, and is hidden from %ie" duringnormal operation &ny pro$lem "ith using theswappartition
(ypically,system datais separate from user data Programs that offer ser%ices are kept in a different place than the data handled $y this ser%ice )ifferent partitions created:
a partition "ith all data necessary to $oot the machinea partition "ith configuration data and ser%er programsone or more partitions containing the data$ase ta$les, user mails, an ftp archi%e etca partition "ith user programs and applicationone or more partitions for the user specific files *home directories+one or more s"ap partitions
7/25/2019 Operating Systems and Linux II
3/25
-o" to check the mounted Partitions
nettech:> df -h .Filesystem Size Used Avail Use% Mounted on/dev/hda7 9!M "#$M7#7M "% /
/dev/hda 9#M "$M &M $9% //dev/hda" "&M .M "!9M % /'/dev/hda( "9) "() &.7) (% /o*t/dev/had# 7.!) (.) ".&) "% /us+/dev/had7 $.7) &.7) #7M 77% /va+
7/25/2019 Operating Systems and Linux II
4/25
/nit process
(he kernel, once it is loaded, finds initin s$in and executes it 0hen initstarts,
it $ecomes the parent or grandparent of all of the processes that start upautomatically on Linux system
(he first thing initdoes, is reading its initialiation file, etcinitta$ (his
instructs initto read an initial configuration script for the en%ironment, "hich
sets the path, starts s"apping, checks the file systems, and so on 3asically, this
step takes care of e%erything that system needs to ha%e done at system
initialiation: setting the clock, initialiing serial ports and so forth
(hen initcontinues to read the etcinitta$ file, "hich descri$es ho" the system
should $e set up in each run le%el and sets the default run level
& run le%el is a configuration of processes &ll !4/56like systems can $e run
in different process configurations, such as the single user mode, "hich is
referred to as run le%el 1 or run le%el # *or s+ /n this mode, only the system
administrator can connect to the system /t is used to perform maintenance
tasks "ithout risks of damaging the system or user data
7/25/2019 Operating Systems and Linux II
5/25
/nit process
0hat is init 8
7/25/2019 Operating Systems and Linux II
6/25
-o" login is initiated
(he idea $ehind operating different ser%ices at different run le%els essentially re%ol%es
around the fact that different systems can $e used in different "ays #ome ser%ices cannot
$e used until the system is in a particular state, or mode, such as $eing ready for more
than one user or ha%ing net"orking a%aila$le
(here are times in "hich you may "ant to operate the system in a lo"er mode 9xamples
are fixing disk corruption pro$lems in run le%el 1 so no other users can possi$ly $e on
the system, or lea%ing a ser%er in run le%el "ithout an 5 session running /n these cases,running ser%ices that depend upon a higher system mode to function does not make sense
$ecause they "ill not "ork correctly any"ay 3y already ha%ing each ser%ice assigned
to start "hen its particular run le%el is reached, you ensure an orderly start up process,
and you can uickly change the mode of the machine "ithout "orrying a$out "hich
ser%ices to manually start or stop
Shutdown
!4/5 "as not made to $e shut do"n, $ut if you really must, use the shutdowncommand
&fter completing the shutdo"n procedure, the 6h option "ill halt the system, "hile 6r "ill
re$oot it
7/25/2019 Operating Systems and Linux II
7/25
Links
-ard links to a file
#oft links to a file
#!/)
7/25/2019 Operating Systems and Linux II
8/25
/nodes in =ile systems
/n a file system, a file is represented $y an inode, a serial num$er
9%ery partition has its o"n set of inodes> throughout a system "ith
multiple partitions, files "ith the same inode num$er can exist
9ach inode descri$es a data structure on the hard disk
0hen a hard disk is initialied to accept data storage, usually during the
initial system installation process or "hen adding extra disks to an existing
system, a fixed num$er of inodes per partition is created
(his num$er "ill $e the maximum amount of files, of all types *including
directories, special files, links etc+ that can exist at the same time on the
partition
7/25/2019 Operating Systems and Linux II
9/25
/node )ata #tructure
At the time a ne, le is c+eated it ets a f+ee inode.
0node contains the follo,in info+mation:
12,ne+ and +ou* o,ne+ of the le.
1File ty*e 3+eula+ di+ecto+y ...4
15e+missions on the le
16ate and time of c+eation last +ead and chane.
16ate and time this info+mation has 'een chaned in the
inode.
1um'e+ of lin8s to this le
1File size
1An add+ess denin the actual location of the le data.
7/25/2019 Operating Systems and Linux II
10/25
Path names and =iles
&$solute path names
Aelati%e path names
Bopy a file or create a link to a file
)eleting files and directories
7/25/2019 Operating Systems and Linux II
11/25
)efault files
#tandard input
#tandard Cutput
#tandard error
7/25/2019 Operating Systems and Linux II
12/25
Linux Processes: 3irth and )eath
7/25/2019 Operating Systems and Linux II
13/25
Linux Processes: #ome facts
#tate: (he execution state of the process *executing, ready,
suspended, stopped, om$ie+
#cheduling information: /nformation needed $y Linux to
schedule processes & process can $e normalor real-timeand
has a priority Aeal6time processes are scheduled $efore normal
processes, and "ithin each category, relati%e priorities can $e
used & counter keeps track of the amount of time a process is
allo"ed to execute
/dentifiers: 9ach process has a uniue identifier and also has
user and group identifiers
7/25/2019 Operating Systems and Linux II
14/25
Linux Processes: #ome facts
/PB: Processes can interact "ith each other
Links: 9ach process includes a link to its parent process, links
to its si$lings, and links to all of its children
(imes and timers: includes process creation time and the
amount of process time so far consumed $y a process
=ile system: pointers to any file opened $y this process, as "ell
as pointers to the current and root directories for this process
&ddress space: Dirtual address space assigned to the process
Processor6specific context: Aegisters and stack info
constituting the context of the process
7/25/2019 Operating Systems and Linux II
15/25
Linux Process #tates
Running: Process is either running or Aeady to run
Interruptible: & $locked state and process is "aiting for an e%ent, such as
end of an /C operation, a%aila$ility of a resource, or asignal from another
process
Uninterruptible: & $locked state Process is "aiting directly on hard"are
conditions and "ill not handle anysignals
Stopped: Process halted and can $e restarted only $y some other process
9g, a process that is $eing de$ugged can $e stopped
Zombie: Process has $een terminated, $ut its structural information is still
in the process ta$le
7/25/2019 Operating Systems and Linux II
16/25
Linux Process Bycle
#topped
Aeady 9xecuting Eom$ie
!ninterrupti$le
/nterrupti$le
#cheduling
Aunning state
#ignal#ignal
9%ent
#ignal or 9%ent
(erminationBreation
7/25/2019 Operating Systems and Linux II
17/25
/nput6Cutput Aedirection
Cutput redirection "ith F and G
Aedirecting HnothingH to an existing file is eual to emptying
the file
same redirection to an nonexistent file "ill create a ne" empty
file "ith the gi%en name
(o find a "ord "ithin some text, display all lines matching
pattern1, or exclude lines also matching pattern2 from $eing
displayed:
greppattern1file | grep -vpattern2
7/25/2019 Operating Systems and Linux II
18/25
/nput6Cutput Aedirection
(o display output of a directory listing one page at a time:
ls 6la G less
(o find a file in a directory:
ls 6l G greppart_of_file_name
"ho G "c Il
aspell J texttxt F errorlog
cat afile FF $file
=ile descriptors
ls F dirlist 2FK1
set 6o noclo$$er
7/25/2019 Operating Systems and Linux II
19/25
&utomatic Processes: )aemons
)aemons are ser%er processes that run continuously
Most of the time, they are initialied at system startup and
then "ait in the $ackground until their ser%ice is reuired
& typical example is the net"orking daemon,xinetd, "hich is
started in almost e%ery $oot procedure &fter the system is
$ooted, the net"ork daemon just sits and "aits until a client program, such as an =(P client, needs to connect
7/25/2019 Operating Systems and Linux II
20/25
Processes
at [options] time
9xecute commands at a specified timeand optional date (he commands are taken
from standard input or from a file
9xample: at 1:@@ am tomorro" J scriptfile
3y default, only a pri%ileged user can execute the command
Aole of script files, eg, etcprofile
7/25/2019 Operating Systems and Linux II
21/25
Bron and Bronta$
(he cron system is managed $y the cron daemon /t gets information a$out "hich programs and "hen to run them from the
system's and users' cronta$ entries
Cnly the root user has access to the system cronta$s, "hile each user
should only ha%e access to his o"n cronta$s Cn some systems *some+users may not ha%e access to the cron facility
&t system startup the cron daemonsearches %arspoolcron for cronta$
entries "hich are named after accounts in etcpass"d, it searches
etccrond, etccronta$, then uses this information e%ery minute to check if there is something to $e done /t executes commands as the user "ho
o"ns the cronta$ file and mails any command output to the o"ner
7/25/2019 Operating Systems and Linux II
22/25
Bron and Bronta$
!sers are supposed to edit their cronta$s in a safe "ay using the crontab e
command (he default editor is vi
(his cronta$ entry reminds $o$ to go to his sports clu$ e%ery (hursdaynight:
$o$:F cronta$ 6l
N *tmpcronta$1
7/25/2019 Operating Systems and Linux II
23/25
(BP/P (esting and (rou$leshooting
ping
(he /P protocol includes control messages called */nternet Bontrol Message
Protocol+ /BMP packets Cne type of /BMP packet is called an echo reuest,''
and the /P rules reuire its recipient to send $ack an echo reply'' (hese are
incredi$ly useful $ecause you can determine *1+ "hether the remote host is up
and talking to the net"ork, *2+ the time reuired for a packet to make a round6trip to the host, and *+ *$y sending a fe" doen echo reuests+ "hat fraction of
the packets sent $et"een the hosts get lost some"here along the "ay (heping
command *named after the sound of an acti%e sonar system+ sends echo
reuests to the host one specifies on the command line, and lists the responses
recei%ed their round trip time 0hen terminatedping*pro$a$ly $y hitting
control6B+ it summaries the results, gi%ing the a%erage round trip time and the
percent packet loss (his command is used constantly to determine "hether
there is a pro$lem "ith the net"ork connection $et"een t"o hosts
7/25/2019 Operating Systems and Linux II
24/25
(BP/P (esting and (rou$leshooting
ping [options host
ping !a: makes response audi$le e%ery time it is recei%ed
ping !i wait:"ait for waitseconds $et"een sending packets
ping !w n: exit ping after nseconds
7/25/2019 Operating Systems and Linux II
25/25
(BP/P (esting and (rou$leshooting
traceroute QoptionsR host QpacketsieR
(BP/P command 0hilepinggi%es information a$out the performance
of the net"ork path $et"een t"o hosts, traceroute"ill actually sho"
the route /t attempts to list the series of hosts through "hich senderSs
packets tra%el on their "ay to a gi%en destination 3y o$ser%ing theoutput of this command, and especially $y follo"ing it up "ithpings of
specific hosts on the route, the exact location of a $ad *high error or
latency+ link can $e disco%ered
&ttempts tracing $y launching !)P pro$e packets "ith a small ((L,
then listening for an /BMP Ttime exceededU gate"ay -ost is the dest
hostname/P address Packetsie is the N$ytes of pro$e datagrams