You are on page 1of 136

m 

 
m  
? Ý 

? 

?     
? 
  
? 
 
?         
?   

? 
 
? 
!  
? "#$    $ 
?  $  

? % $ 


? 
& $
?    
? $' ($ )*+  ,


? Æ
  
 
? 
 m      
?         
Ý   
?    
 
?   !"#$%mm&m'!    
   "($)
? Æ
  Æ*+
? + ,  
? +-  "($)m%
? .      "($)  
g    
? ,  
? /  
? 0  
? Æ
? %   
? 1 

? m   

?    
?    
? 
   
?  
       2
9  
?        2 
1
3
? 9      2 

 Æ  3
? ë        2 #   3
?    
m      2 m% 4

  3
? Ô    2 % 
53
? g    2 $   , !
%
 3
? m 
   2 m ! 3
?  m   
 "($)* 2
 
   
 3
9
  
? Ý      2 6 *2 % 3
?      2 m  1 
$3
?     2 1   # 3
$3
? g   !m)    2 


% 
 3
? 9 m  mm     2 ,mÆ3
? ’   "7* 2      
 
3
9 
 
? ! "
? ! 2
?   
? m 
? !  
? !  
9 
 
server

-Several users can use the computer at the same time.


Unix uses time slicing to enhance multi user environment.
9 
 
? ! 2

’ lti Taski - Perf r se eral tasks at t e sa e ti e.

0 t 1 t
e tasks are laced i t e back r d w ile t e
ser c ti es t w rk i t e f re r d.
A back r d task is essetially a  - iteracti e task.
9 
 
?   
     
  
  8    3

?  9*    
 

?  Æ*     3

?  

 *  


  
 
   3
9 
 
!  
T e ’d lar desi 
f t e O/ allws ari s
arts f t e i syste
t be added r re ed
accrdi t req ire et
wit  t affecti t e
erfr ae f t er
ets.
g  
ñ    m   
 g 
"
? m"
User Interactivec
comman s omman s
an ata

rompt utput utput

m    
*******************************
***
Ôransfer
,  *%  
of control
Re uest for
services

"7   ÆÆ  


  
? %  "($)
? $      
? $   
  "($)   
?         
?   2    $9   Æ
Æ  
?  
  

  2 


  
? ! 
?   
? 0   
? '  
? $9 
? Æ  
? m 
Œm 
? m     7

 3#2  
    

  
  
   3   
  %!!(Æm3

? m
       
      3
m   
? $ :        3
?       
     
 3
?   
  2   
7      
 3
? :



      


  7  3
? /  
      
 
3
{
 
?  
   "7   
     "73
?   
 2 * 
 
   
,   
 Æ 13 ;, 
#  3
? 
 
 , * 
   
   ,   * 3
? ‘m 
  Ô‘m  
 *   
 %
   <** 7 3
?  m 
 
* "7 3
{
 
 
? 
   
? 
993 3 3 9 7
9
9
=3 

? Ô  m ‘     # 


? 
9932  3 9

? 
  ’
? 
99 3 
39   9  99 > 3

? Ô ‘ m   
? 
99333 9  93

Ô   m ’


? 
9943  3 9Æ 9  94> 3
{
 
? &       
2

? :99 

? &        2

? : :m6'##
9 m  
?          
   3    
        3
File hierarchy

m  m  
 
 

   
 



Ô    
?    
? Æ   
? m
  ?  @
? %    
? , 2  
? 0$0 
9   
? !7A   
? (  
 
     
? ! 
       
? (   
 
? m    
? %
   
? Æ  
      
  *  
? 6    
? Æ   
 *    
   2
? %    
? Æ          
m       
  
? 9*       
? 9*        "($)  
? 9  *           "($)
  
? 9 *     
? 9 *       %
 
? 9
*   
  
9     
? ' "($)   
3

? 
7 
    5 $Æ?

  @3

?      3      7


    
  3
9 g  
? 1

?   1
! 
?99
 @
? m   1
! 
?99
@
? B
C 

? '         

? Æ    
   
? B
C B C  
g ñ
? P P     
? ~ [ [X    
 

? '7

?          
7 ?   @3
?             
 *  *       
 *  7   ?33 
  7 @3
Π 
? !     
? V !  
? *  !    
  2
? * !  
   
   3
? *  !    

 
 2
-
 
- tes Nae ’eai
?    
 5  

 
le - tes  
le - tes -  thi eclse i 
le tes reve eai f that characters (except \ a $).

' Sile tes 'Sile tes' - Eclse i sile tes reais chae .

` Bac te
`Bac te` - Ô exec te ca
   


 7  
? m 

@0   

=@,2  

?  6 
? !    
 2 
 
 
? # 

8 


?  

   
? [ r   2 
? ~ 2 8    
?  
 8  
  
? î 2   
  8 
? ºî  8 
? ô    8   
? a PP 2 8   
?r  

? a PP
2 
  =A-
ñ    
ñ  
? m  

? !  2
     
 
  3      
    2    3
?      2  3 
    
 3
?  
     
2  3
?    
? 2  ?   @
?  ?    @
?   
 ?

 @
ñ    

?     
    
2  3    
 BDB3
? '3
? :D 
? 6   
 ?  @
      2   2  3
? $
2  
 B*C  
    5  2
3'3
? :E  
D     
  
B CF
ñ    


?    
    
 
 
?   3"  ?    @
? 0 
? $
   
 
?       BFC
  3
? '3: F 
? 6         2
 B C3
? '3: FF 
? FF   

  
   
   3
ñ     
?          3
? '  B    C   

    3
? /   B=FC  
     <
? ':  =F  3
? 6  B  C C7   
 B(       C   
 B  C   
   3
? B=C    
    3$
G     
  
  

    7
 
  
 
     
  3
¬  
  
¬ 

     

m  
  

  
   
 


   
 
  
m              

          
 



   
m             

 
    
  

m 
  
Examp !
pt

md1 | cmd2 P
pe stdout from one command to std
n of another.
cmd < f
e Read std
n from a f
e.
cmd << text Read std
n unt
 reach
ng a 
ne
dent
ca to p p .
cmd > f
e Red
rect stdout to a f
e. (overwr
te
f f
e ex
sts)
cmd >> f
e Append stdout to a f
e.
cmd 2>f
e Red
rect stderr to a f
e. (overwr
te
f f
e ex
sts)
cmd 2>>f
e Append stderr to a f
e.
’
  
Example Description
cmd1 2>&1 | Pipe stdout and stderr from one command to stdin of another.
cmd2
cmd < f1 > f2 Redirect stdin and stdout simultaneously.
cmd > file 2>&1 Redirect both stdout and stderr to a file. (overwrite if file
exists)
cmd >> file Append both stdout and stderr to a file.
2>&1
cmd > f1 2> f2 Redirect stdout to the file ô and stderr to the file ô . (overwrite
if the files exist)
cmd >> f1 2>> Append stdout to the file ô and append stderr to the file ô .
f2
cmd | tee f1 Redirect stdout to the screen and to the file ô . (overwrites ô 
if it exists)
cmd | tee -a f1 Redirect stdout to the screen and append it to the file ô .
£   
E m
m ; m E m mm m
{ m ; m ;E} m mm g
m ; m E m mm g
E m g

m m E ~  x E ~    ~  

x 


 
 x
m   m  E

~  x E

~    ~   x   


 
 
? rire Ȃ outrut of one command is surrlied as inrut to
6
another

? tee Ȃ read standard inrut & writes to std o/r & the file of
user choice
  
  
Ôo create a Unix user id following information is required
 ’   
1. User Name

2. User Id

3. Grour Id

4. Home directory

5. Login shell
? User name Ȃ must be unique consisting of 2-8 letters
 ’   
and numerals
? User id Ȃ Unique user id ranging from 100 to 60,000.
User IDǯs 0-100 reserved for system users
? Grour id Ȃ unique numerical id to which the user
belongs. Ranges from 100-60,000
? Home directory Ȃ identifies userǯs home directory rath
? Login shell Ȃ identifies the user shell
Various shells are:
Bourne shell (sh), korn shell (ksh), C shell (csh), bash shell
(bash)
Ôhe user and grour information is stored in following files:
 £ ¬  
/etc/rasswd

/etc/shadow

/etc/grours
 
Àrerates in two modes
w 
? Insert mode

? Command mode

Pressing [Esc] key returns the editor in command mode


? Insert before cursor, before line i, I
¬   
? Arrend after cursor, after line a, A

? Àren new line after, line before o, À

? Rerlace one char, many char r, R


? Character to right, left x, X
Æ 
? Ôo end of line D

? Line dd

? Word dw
Corying is called yanking in vi
‘  
Yanking Ôext
? Line yy
? Character
yl

Pasting is referred to as Putting text in vi

Putting Ôext
? Put after rosition or line r
? Put before rosition or line P
? mearch forward /string
m    
? mearch backward ?string

? Rereat search in same, reverse directions n, N


Ôhe search and rerlace command is accomrlished with


:s

Ôhe syntax is
:%s/rattern/string/flags
Àr
:start line no., end line no. s/rattern/string/flags

flags Ȃ g, c
? Exit saving changes :wq
- 
? Quit (unless changes) :q

? Quit (force, even if unsaved) :q!

? Write (forcibly) :w!


 
Ô  
?  
   
 
 2   HH3

      B9C3

? / 
 :


 

 3

?  

  
  
  2    
7
mIJ:/ÆFJ
?  

  

 3
 ?  @3
    
? $  %  
?      3
? '3 

? '7  %  


? 
 

 3

? m
  
? %2  * 
? %2 

? m 6E      
   
g m
? m
 7  
?  4   
? 0   
? m %  
? m     
? / 27
? %   
 
?      
?      
?    
 m


?         
   
     3

? '3
? : K  H
 
   

? : K L LH


 

  ÆGMMM%m=GG-
Ý 
1


?  [      



   
? J  [    
  
 
m    
?    

?           

?    
       
?       
   

?    
     
?        !
 
  
      " 3
ë9    
?P      
? P       
  
? a  2   
? ~ 
[
     
? ~   *   
? ~   
    
? rJ 

  
  
 9 
? ~r  
    =
?          =
?     
?   
[
    
? ~  
 
?  
 

?  
    
?  P 
    
? r a [
     2 
? J~       9 9  
  
G ‘ 
? rs Ȃ rerort rrocess status

? -e Lists information about all rrocess now running
? -f Full listing

? echo Ȃ echo arguments


? \c Continues the outrut on the same line
? echo DzHello World!dz

? chmod Ȃ change mode


? chmod 755 <filename>

? ls Ȃ directory listing
? -a list all entries including those beginning with .
? -l long listing
G ‘ 
? cat Ȃ concatenate and disrlay files
‘  
? -b number the lines as in Ȃn but omit numbers for blank line
? -s silent about non-existent files
? cat <filename>
? find Ȃ find files
? -name Ôrue if rattern matches the current file name
? -rrint causes current rath name to be rrinted
? find <rathname> -name <filename> -rrint
? grer Ȃ search a file for a rattern
? -l rrint only the name of the file with matching lines
? -v rrint all lines excert those that contain the rattern
? date Ȃ write the date and time
? date Ǯ+%m%d%yǯ
? -u Ȃ disrlay the date in GMÔ
G ‘  ‘  
? cr Ȃ cory files
? -i interactive cory
? -r cory files and subdirectories
? cr <source_filename> <destination_filename>
? mv Ȃ move files
? -i asks for confirmation before moving if file already exists
? -f move without rromrting
? rm Ȃ remove files
? mame ortions as cr/mv
? who Ȃ who is on the system
? -m Ȃ outrut info about current terminal
? -q Ȃ disrlay only names and number of users currently logged in
? whoami Ȃ disrlay the effective current username
G ‘ 
? rwd Ȃ rrint working directory
‘  
? wc Ȃ line, word and character count in a file
? -l Ȃ count number of lines
? -w Ȃ count number of words

? more Ȃ list file contents by screen


? -c Ȃ clear before disrlaying
? -w Ȃ rromrts and waits for key to be hit before exiting

? diff Ȃ show difference between two files


? -i Ȃ ignore the case of the letters
? -w Ȃ ignore all blanks and sraces
? diff Ȃw <first filename> <second filename>
G
? cut
‘  ‘  
? -c Ȃ list following c srecifies char rositions eq Ȃc1-72
? -d Ȃ delimiter
? -f Ȃ show fields serarated by delimiter
? cut Ȃc1-10 <filename>

? raste
? -d Ȃ delimiter character
? -s Ȃ concatenate each serarate line in a file into a single line
? raste <first filename> <second filename> > <Àut_filename>

? sort Ȃ sort the file


? -r Ȃ reverse the sorting direction
? -n Ȃ restricts sort key to initial numeric value
G ‘ 
? tee Ȃ send outrut to terminal and file
‘  
? -a Ȃ arrend the outrut to existing file

? uniq Ȃ show unique lines in a file


? -d Ȃ surrress the writing of lines that are not rereated in the inrut
? -u Ȃ surrress the writing of lines that are rereated in the inrut

? exrr Ȃ evaluate an exrression

? head Ȃ outrut beginning of file


? -n number Ȃ the first number of lines will be shown on std outrut

? tail Ȃ outrut end of file


G ‘ 
? ln Ȃ link to other file
‘  
? -f Ȃ link files without questioning the user
? -s Ȃ create a symbolic link

? file Ȃ show the file tyre


? -h Ȃ do not follow symbolic links

? tr Ȃ translate characters
? tr Ǯ[a-z]ǯ Ǯ[A-Z]ǯ < <inrut_filename>
? shift

? alias Ȃ disrlay command aliases


? Works in ksh and csh
? alias dir=Ǯls Ȃl|grer dǯ
ë
? 0    

? 6 #2
? %  
? (     
? m7ln filename linkname

? m #2
? %  
?       
? m7ln Ȃs filename linkname
  
 
? 5 
? 
?
?  

? 4

?  
?  
?     BNC
? '    
 
? '   
  
 
? '     
   
? '    
       
m m  
? mhell mcrirt is   $ written  

Œm
 . mhell scrirt is just like batch
m  file is Mm-DÀm but
have more rower than the Mm-DÀm batch file

? (    



? m  
2
      

 3
? "       3
? m  3
?     2     3
? m   
     
m  
? ( 
     5   3
? (  4    3
? m      I
  3
? m       :3
?       4     3
? '3
:7IG O 
    I
: :7 O: 5     3
? P    
 83
? '
:4I:7:
    
?   
  variables  3
            
    
 3
? '36
      
     
 


3
?   7
   Ý    
 
      
D  #Ý’

? "   2    

Ý    
? "72    
 


99
  
 
 
 3
? 7
 
*

 
                 
     
   D !
  "  # $
  
    % #  $   &  '
  ( 

) *
?     
7 
    
 
 

   
? '3D  +) ' ' 
 D  ,-- ' ' 

? '7   



? D
 ' ' 
D  ' ' 
D .' ' 

? %   

O  7     
 
 3
? /  Q
 ë g
 
   9  
   3
3
=3 $   9    
   

?  9   @3
? ':   

? Im m 
33    :G

? =I0      


   33
  :
? -Im       
   33
  :=
? :O  *        36 
:OI=
? "  
?    @ 2   
ñ  m 
? @   3   
? myntax:
     =333  (
? '3:  

? / 7  


     


        


5            3
? $  7      7
        3
? $
     9  
7    
m
  
 
      
     
7      3
? $  value is zero ?G@    3

? $  value is nonzero      


    7   9  
3

?    7m   #$ 


 
    3
? '3 : 
: :Q
$ 
G    B C  3
m       
mm
e a
a ee mncance

D D   
   

D     
      




  
 
  

D     
      




   

   
D  
    




D  


D      


DD  !" " 
 
 
?  
  
     7   
   
      
 
  3

? myntax: $   ;;  =


* %  =7         
7  4 3

? myntax:   RR  =


* %  =7         
 *4 7 3
? ,    
 
 RR  -
myntax:   ;;  =7 4
7  *4

Examrle:
 
BSC99
 RR   
$ 
           7 


 
EBSC99
 ;;   
" ;; RR 
 
EBSC99
 ;;   RRT
 KL L     H
m  Ô 
? B7C   
   

 3
? /    

7           
 
   3
?   
  B7C
  3
? $ 
   
  
      3
? $   
      
4 3
    
? $      7  
   =7 
9 #
? myntax: 9#

~   ~  


"
"


~ ~ 
~ ~ 
  

~ ~ 


     
? myntax:
ô~  
 
~   
  
~ ~   
P ô ~  

~   
  
~ ~   
P ô
   ~  ~    
~ ~   
ô
 
    
? BC       
3
?   
        
  
Rea na
pe
a   7 3
eann
? (  $ 
      
$  
 3 
 $ 
 % "

 % "


$ 
  & "

  & "
$ 
 m  
Ôes x saus


  '  
  

 

   '  
  
 

(  '  
 ( 

)(  '  
  
$  

 '  
   



 
 9 Ô 
Ôes eann

   
  

  9  


  

  

  !  

  

     

   


 

     
ë  
? #  
          
   
pe a eann

)  
&   *'

  
   
 &   !

  
   
 &  *+
 m  
? 1    !   ** *3
?  ) %
?  D  
 ~ ~ 
 ~ ~ 
 ~ ~ 
~ ~ 



? "    /0     )       .


 m    
 D  
 0   1 D  2.3*  4$$
5 0   1 D  2.6*  4$$
70   1 D  2.-  4$$

  0   1 D  3*   4$$
/0     8     D   $$

 
? #
7       3
? myntax:
?   *~  

command1
command2
command3
ǥ..

? % 
B C 
?   <
  
U33

    
  9 D ' 6* :   5       6*

  ; 
  % D<
 
ë
? m7
 l ! l!

~   ~ 
 
" # 
  
 
?  ) 3 %
 ==  $  $  00

#  
 $%&
 
9
 
? 9 
 



 
 

 






?  




  !"#$


!"% 
 "&'(

 



ƒ
9
   
? /  
  
  :G:3 
     
? /       73
? 0     
  3& 

   

3   


)
   
 
 

 *!"*+**#$

!",- 




- 


  
?    

  
  

     
  
 
       


? G;=       


    
 
?       
 
  - 
      
   
 

 2     3

    
7        
    
?     7

m
% 
7D;G O#2   
 O 
7D *  O  
  * 

 

 :
7GD;D;* O      O  
O    

    
?     7

m
% 
#10$#'I  37
7F; O#2   
 O 
7F:#10$#' O  
  * 
 K#  H


7F;D;* O      O  


O    

m 
  
 
   , " " "
 - -  "
 - - -"
./0 .  0  - 
.)/0 -.) 0 - -
1# -1 #2 -      -
    
 
   , " " "
31#2 31 #2      
1#2 1 #2      
1#2 1 #2   " 
)1#2 )1 #2 "     
4$ 4 $    
 m  


0   
??> >II> =>@@   5 
??> >NI> =>@@    5 
??> >D> =>@@
??> >F> =>@@
??> >DI> =>@@
??> >FI> =>@@
 m  
m  

0   
VV> >II> =>WW  5 
VV> >NI> =>WW   5 
VV> >D> =>WW
VV> >F> =>WW
VV> >I>
 >WW
VV> >NI>
 >WW
VV*4> >WW  
VV*> >WW   
V7IE 2I8W 7
 
V7IE2I8W  7
 
9   
 


$>7
>
> ?@>
 >7
>
> ?@>
 
> ?@>

9     



> >
>
 >@> ?@><<
>
 =>@> ?@><<
X@ 2<<

9     
 

 >7
>

> ?@>

9     
 

 >  >> >



> ?@>

9     
 

 >7
>

> ?@>

  
      :G
    :33:
   :Yƒ
(   
  
  :O
' 
  
  :Z:X
P     7   :Q
   ::
   2    :N
ñ  
G  
 
= 

D;*   


F;*   
DF 
    * 
=F;
=   

 
  
PI:YP=IP-ƒ mP  P= 
  P  P-
:YPQ ƒ P;PNI("##  :P 

  7
:YPI ƒ PNRPE  PI:
:YP* ƒ P;PNI  :P  
:YP[ ƒ P;PNI     
 
:YPO
ƒ 
    P
  P 
   P
:YP\
ƒ 
     P  
P 
   P
 
 ! -
 

?   *   
? $
  7    
 
? m'Æ 22   
  
?@
 
 5   
? m7
 
 B  C 
? m     
? ,  
? ,

    
     
 
? '7
*
 B-5C 
E* 
 -  
 EB=M
C 
** 
 = M  
 EB:
C 
** 
  
 EB-:N
C 
** 
;=  
 EEBM
CCGM
CC=G:
C 
** 
*MG*M;=G*   
  g  
? '7
*
 EB99
C 
E    KH  
   
 EB999 9
C 
E    KH B C 
   
 EB99
C 
E 
  ;   KH 
  
 
 EB9VWV74W9
 
*  
 ;74  
3
 B:T
  

 T
(7 
C F =* 

      
     
  3
  g  
'7
*
 BT
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
B 
* $ X 
 B99 C 
* Æ    

 B:9 9 =9C 
*    =
 EB9
 9 
9
 =9 =C 
*/   
  
 EE
    
*$ 
  
   
?    

 B9D
 F9D 
F9CD FFD F

? $ 
    
 B9S9 9CD F

? Æ
  2 
 EB9"799 9
CD F

?       


 EG
D F
   
?   
      
 G D F

? !2 
    

 1D F

? m

 
   
 -5D F

? Æ  2 


 B9S:9 CD F
 9
 
 !  


"

5  
'
67
 5    
 
67  "



5  
   
67 
"
 "

Ý      
? m   
  7 2 
  
3

? $!'IL R J93X3X3XT?3XT@3X3X9T9JL




? 2  
   
 9 


   3

? "2   


72    
  
  3
? $   
 3
? $   m  
 
  B%C
  # 3
? m7
2
 B Y ƒC ?@
    
, "   ,


? 0     2
1!*'2 , "
"  
 , " "  
% , " 




D , "


5   "   

.0 & 
4$ , "



3 , "
 

 , " 
 

   
a k a abe eann
2
9 &", " 

 
+8
   "  1!   


2
*98 *       
1-
   2
*+8 *     
1!   

2
"+ " 

"9 "    


*9,' *  
 
98 9     "  1-
9    2
"

 
? 2 9
 
!   


12 +

 

$12 +
" $ 


" +
" 
""


"12 +
" 
""

 1   8 8



&2

1  2
   
 
 


1 
 8  

 

 
2  

 1: +
<



;2
  
?  2
? "     2
?

? 2
 
*0 0 m
 
* $ 2 
 

 1%   %  1P #   



    
 
? 2 pe mncance
a
6 & "

6( & "
$ 

7 % "

7( % "
$ 

(( $ 

)( "$ 
   
? 1  7    
myntx:
?   @
Y
m
m=
m(
    "'
ƒ
 
Y
m
m=
m(
   0#m'
ƒ
ë 
? 0   
    
2
? m7 

 ?7
<   <7
=@
Y
m
m=
m(
ƒ
ë   
? m7 

 ?   @


Y

=
(
%       "'
ƒ
?2