Linux 033_

Embed Size (px)

Citation preview

  • 8/12/2019 Linux 033_

    1/40

    1. Idea and History of Linux

    2. Linux Usage Basic

    3. Browsing the file system

    4. User, rou! and "ermission

    #. Using $he Bash %hell

    &. %tandard In!ut ' (ut!ut and "i!es

    ). $ext "rocessing $ool

    1

  • 8/12/2019 Linux 033_

    2/40

    U*I$+1Idea and History of Linux

    First Linux version (UNIX) operating system developed by -en $hom!son and /ennis

    0itchiein $ $ Bells La U.%. in 1970 or! on "UI mode#154*Upro$e%t as introdu%ed (&rap'i%al Not UNIX) it as an organiation t'e aim ot'is organiation to develop t'e %lone o U*I6 *perating +ystem#15) 7inix -ernel as introdu%ed by LINUS TORVALD a &raduate student o,HELKENSI UNIVERSITY

    Linux (rigin8 + Linus $or9alds%reated its -:0*:L in 1991#

    it' assistan%e rom programmers around t'e orld

    irst posted on Internet in 1991

    Linux 1#0 in 199-. /#/ in 1999

    oday used on 710 million %omputers

    it' 10002s o programmers or!ing to en'an%e it;hat is Linux < 3 ullynetor!ed 4/56-it Unixli!e *perating +ystem

    Unix ools Li!e sed8 a!8 and grep (explained later)

    "ompilers Li!e "8 "8 Fortran8 +malltal!8 3da

    Netor! ools Li!e telnet8 tp8 ping8 tra%eroute

    :ultiuser8 :ultitas!ing8 :ultipro%essor

    ;as t'e X

  • 8/12/2019 Linux 033_

    3/40

    ;hat is -ernel*+ or

  • 8/12/2019 Linux 033_

    4/40

    1# ?%onomi%al to use 1# Not ?%onomi%al to use/# :ore +e%urity /# Less +e%urity4# :ostly or! in AUI 4# :ostly

  • 8/12/2019 Linux 033_

    5/40

    ;hat is ;I*/(;%es!top environments provided by =ed ;at# 1# *(7:t'e deault

    6

  • 8/12/2019 Linux 033_

    7/40

    %im!le 9iew of *(7: /esto!

    des!top environment# /# -/: an alternate des!top envoirment#

    7

  • 8/12/2019 Linux 033_

    8/40

    %im!le 9iew of -/: /esto!

    +tart ,X sit%' text base to grap'i%al#

    =ollowing commands are used to create a new file N3N* ?asy8 ?ditor8 +imple

    AI ?asy8 ?ditor8 +imple

    AI: 3dvan%ed eatured it' ?n%ryption

    &AI:

    Basic =ile editing 9i editor vi t'e basi% text editor t'ree modes

    M "ommand mode O deault startupM Insert modeM ex mode

    vi netor!nuts O a typi%al exampleM ?nter insert mode iP and "=PM ?nter ?+"P return to %ommand modeM Navigate t'e %ursor

    M hmove %ursor letM jmoves %ursor donM kmoves %ursor upM lmoves %ursor rig't

    @

  • 8/12/2019 Linux 033_

    9/40

    %ome %im!le Aommands ls O list t'e iles and dire%tory

    date O display date and time

    cal O display %alendar

    clear O %lear t'e s%reen

    !wd O prints t'e name o %urrent or!ing dire%tory mdir O %reates t'e dire%tory

    rmdir O removes t'e dire%tory

    cd O %'anges t'e dire%tory

    cat O display t'e %ontents o ile

    rm O removes t'e iles

    c! O %opy t'e iles and dire%tory

    m9 O move and rename ( iles and dire%tories )

    touch O updates t'e ile5dire%tory timestamps

    less O pager %ommand

    more O pager %ommand

    Aommands & O go to last line in ile 1& O go to irst line in ile ; O go to irst line on s%reen : O go to middle line on s%reen L O go to last line on s%reen ?nterP O ma!e %urrent line irst line on s%reen O ma!e %urrent line last line on s%reen QQdate O Inserts t'e %urrent date and time in to ile QRsort O +orts t'e data o your ile

    QRmt 66 O ormats t'e data o your ile in to 66 %olumn idt'?x mode G +ear%' and =epla%e %ommand

    GSs5big5smallGSs5big5small5g

    o display t'e list o iles E >ire%tories e use ,ls %ommand#lue "olor ,>ire%tories and

  • 8/12/2019 Linux 033_

    10/40

    Listing directory content8+ Ls to s'o t'e list o iles E dire%tory

    Ls a in%lude 'idden iles

    Ls l display extra inormation

    Ls r re%urse t'roug' dire%tories Ls ld dire%tories and symlin! inormation

    Areating a user8 + J T Useradd usernameJ T passd username

    1. mdir to %reate a dire%tory (T m!dir dirname)2. cd to %'ange t'e dire%tory (T %d dirname)3. cd .. to %ome out rom previous dire%tory (T %d ##)4. cd to go at previous or!ing dire%tory (T %d )#. cd to go at t'e ;ome (V) dire%tory (T %d)&. !wd to display present or!ing dire%tory (T pd)). rmto remove t'e ile ( T rm WoptionR ile name#

    *ptions are i intera%tive r re%urse or%eully 5. rmdir to remove empty dire%tory (T rmdir dirname) . rmdir r dirname to remove any ile E dire%tory are exists#

    $he location of a file and directory can e s!ecified y two methods

    solute 0elati9e

    1# egin it' a orard slas' 1# >o not begin it' slas'/# "omplete ,road map to ile lo%ation /# +pe%iy lo%ation relative to your

    "urrent or!ing dire%tory#4# "an be used any time you is' to spe%iy 4#"an be used as a stored ay to a ile name# spe%iy a ile name#

    10

  • 8/12/2019 Linux 033_

    11/40

    :nd of U*I$+2

    Unit+4Browsing the file system

  • 8/12/2019 Linux 033_

    12/40

    13. $he '!roc' /irectory +%ontains spe%ial iles t'at eit'er extra%t inormation rom orsend inormation to t'e !ernel# ?xamples in%lude system memory8 %pu inormation8'ardare %oniguration et%#

    14. $he 'sin' /irectory +stores exe%utables used by t'e root user# 'e exe%utables in5sbin5 are used at boot time8 or system administration and to perorm systemre%overy operations#

    Ao!ying files and /irectories

    I t'e destination is a dire%tory8 t'e %opy is pla%ed t'ere

    I t'e destination is a ile8 t'e %opy is overrites t'e destination#

    I t'e destination does not exist8 t'e %opy renamed#

    Aommand c! source add destination add

    Aommand c! Eo!tionD filename 'dirname

    +I M as me efore o9erwriting a file.

    +r M recursi9ely co!y an entire directory tree.

    +! M !ermission, ownershi!, time stam!s.

    7o9e and renaming files directory:ove %ommand is used to move a ile or dire%tory rom sour%e to destination#

    (0

    :ove %ommand is used to rename a ile or dire%tory

    *ote8 + i t'e destination is not rea%'able t'en it renames t'e ile or dire%tory#

    Aommand8 + mvEo!tionD filename destination

    =or exam!le8 + %reate to dire%tory named aa8 bb#

    VJ T m!dir aa bbVJ T %d aaaaJ T nano '%laaJ T mv '%l 5root5bbaaJ T %dVJ T %d bbbbJ T llNo your ile '%l 'as moved rom aa to bb#

    *autilus8+ grap'i%al ile system broser#

    :nd of U*I$+4

    1/

  • 8/12/2019 Linux 033_

    13/40

    Unit+#User, rou!, and "ermission

    ;hat is User ccount < no# (UI>)# (UI>0) identiy root#

    User2s name and UI> are stored in 5et%5passd#

    User and assigned a 'ome dire%tory and a program t'at is run 'en t'ey log in%asually a s'ell#

    User %an not read8 rite or exe%ute ea%' ot'er8 iles it'out permission#

    *oteto see UI> run t'e VJ T "at 5et%5passd#

    ;hat is rou! < Is a %olle%tion o users 'i%' ma!e easy or administrators to perorm t'e tas! o

    administration level 'en t'ey need to apply permissions and restri%tions it' samelevel to many o t'e users8 t'en su%' permission and restri%tions %an be applied torelated group#

    rou!8+ User2s are assigned to a group#

    ?a%' group is assigned a uniDue group I> no# (&I>)#

    &I> is stored in 5et%5group#

    ?a%' user is given t'eir on private group# "an be added to ot'er groups oradditional a%%ess#

    3ll users in a group %an s'are a ile t'at belongs to t'e group# *ote to see &I> run t'e VJ T "at 5et%5group

    $he root user 'e rootuserG a spe%ial administrative a%%ount

    M +ame li!e ,Administrator e %alled in

  • 8/12/2019 Linux 033_

    14/40

    "ermission $y!es"ermissions+ %ymolic 7ethodFour symbols are used 'en displaying permission#

    08 + permission to read a ile or list a dire%tories %ontent#

    ;8 + permission to rite a ile or %reate and remove iles rom a dire%tory#

    68 + permission to exe%ute a program or %'ange into a dire%tory and do a longlisting o t'e dire%tory#

    +G no permission in pla%e o t'e r8 8 x#

    "ermissions+ *umeric 7ethod Four numbers are used 'en displaying or applying permissions

    M 4 Cermission to read a ile or list a dire%tory2s %ontentsM 2 Cermission to rite to a ile or %reate and remove iles rom a

    dire%toryM 1 Cermission to exe%ute a program or %'ange into a dire%tory

    and do a long listing o t'e dire%tory

    M no permission ( in pla%e o t'e 48 28 or 1)

    :xamining "ermission File permission may be vieed using VJ [ ls l 5bin5login

    rxrxrxl root root 190@0 3pr 1 1@G/6 5bin5login

    File type and permissions are represented by a 10 %'ara%ter string#

    Ahanging =ile (wnershi! *nly root %an %'ange a ile2s oner#

    *nly root or t'e oner %an %'ange a ile2s group#

    *ner s'ip is %'anged it' chown#

    VJ T %'on rJ username ile5dirname

    &roup oners'ip is %'anged it' chgr!

    VJ T %'grp rJ groupname ile5dirname#

    o %'ange a%%ess mode it' chmod

    VJ T %'mod rJ mode ile

  • 8/12/2019 Linux 033_

    15/40

    !!lying "ermission with *umeric 7ethod1# - (or read)/# / (or rite)4# 1 (or exe%ute)

    :xam!le8 + KD %'mod 6-0 ile name I u ants to give t'e read8 rite8 permission to oner t'en %ombined t'e

    bot' digit %ode (-/O6)8 and read permission to group (-)8 and or ot'er2s onpermission t'en (0)#chmod%ommand is used to %'ange a%%ess modes

    Numeri% :et'od

    M chmod &&4 somefileile name(&rants =ead and

  • 8/12/2019 Linux 033_

    16/40

    Unit+&Using the ash shell

    ;hat is shell scri!t < +'ell s%ripts are text iles t'at %ontains a series o %ommands or statements to be

    exe%uted

    +'ell s%ripts are useul or

    3utomating %ommonly used %ommands

    Cerorming system administration and troubles'ooting

    "reating simple appli%ations

    :anipulation o text or iles#

    +'ell ma!es an intera%e beteen Users E \ernel# 'ere are t'ree main s'ells or UNIX isG 1. Bourn %hell

    2. A %hell3. -orn %hell

    No a days as' s'ell be%ome popular in Linux *5+# roun again s'ell(as' s'ell) as released Brain fox chief 0emeyas part o t'e ree sotareoundation# 'e *Upro$e%t eatures o as' s'ell areG 1# Input and output redire%tion#/# Use o ild %ard#4# "ommand line editing#-# ]ilde representationB# uilt in s'ell %ommand E Aariables#6# "ommand 'istory and aliasing#

    Aommand line %hortcuts1# (Z) :at%' ero or more %'ara%ters#/# () :at%' any single#4# (09) :at%' a range o number#-# (ab%) :at%' any o t'e %'ara%ter in t'e list#B# (^ab%) :at%' all %'ara%ter in t'e list#

    *otes8 +=emove all iles in extension #mp4 e use#

    +yntaxG VJ T rm Zmp4=emove all iles in extension #txt e use#

    +yntaxG VJ T rm Ztxt

    o s'o t'e ile 'i%' 'ave se%ond %'ara%ter it' K*2 alp'abate+yntaxG VJ T e%'o *Z

    o s'o t'e ile 'i%' 'ave 'ird %'ara%ter it' K:2 alp'abate+yntaxG VJ T e%'o mZ

    VJ T ls a press tab !ey to times#VJ T %at a press tab !ey to times#

    ('is %ommand is used to s'o t'e ile E dire%tories start it' letter Ka2 as li!e a$ay#txt)Q %'ar repeat last %ommand t'at start it' %'ara%ter#

    16

  • 8/12/2019 Linux 033_

    17/40

    +yntaxG VJ T Q %'ar?xampleG VJ T Q d (any %'ara%ter alp'abate)

    Q num repeat last %ommand by t'is no# in 'istory output#+yntaxG VJ T Q num?xampleG VJ T QB

    VJ T m!dir C or!5Winbox8outbox8pendingR5Wnormal8urgent8importantR

    ;or

    Inox (utox "ending

    *ormal Urgent Im! *ormal Urgent Im! *ormal Urgent Im!

    $o Ahec $his8 +VJ T ls'en it s'os (or! dire%tory)VJ T %d or!

  • 8/12/2019 Linux 033_

    18/40

    7ae a %cri!t*pen a ne ile it' KAI2 editor li!e VJ T vi ilename and type t'e olloingVJ T vi ilenameCress ,I or insert mode#T Q5bin5bas'T t'is s%ript display?%'o ,t'e date E time are [ (date)?%'o ,your or!ing dire%tory is [ (pd)?%'o ,your iles E >ir# 3re [ (ls a)?%'o ,your virtual %onsoles open are [ ('o)

    Cress ,:%A !ey8wN

    o run t'e ile VJ T .'filename%te! 28+:a!e t'e s%ript exe%utable

    VJ T %'mod ux ilenameo exe%ute t'e ne s%riptG

    1# Cla%e t'e s%ript ile in a dire%tory in a exe%utable pat'/# +pe%iying t'e absolute or relative pat' to t'e s%ript on t'e %ommand line#

    ;riting "rograms using ash scri!ting%am!le "rogram 1

    T +imple Crogram or users input

    e%'o n _?nter our Name G_

    read a

    e%'o n _?nter our 3ge G_ read b

    e%'o _;ello >ear [a your age is [b ears_%am!le "rogram 2

    T 3ddition o 3 and number

    e%'o n _?nter First number G_

    read a

    e%'o n _?nter +e%ond number G_

    read b

    %O`expr [a [b`

    e%'o _=esult is_ [%%am!le "rogram 3

    T :ultiply 3 and

    e%'o n _?nter First number G_

    read a

    e%'o n _?nter +e%ond number G_

    read b

    %O`expr [a YZ [b`

    1@

  • 8/12/2019 Linux 033_

    19/40

    e%'o _=esult is_ [%%am!le "rogram 4

    T >ivides 3 rom

    e%'o n _?nter First number G_

    read a

    e%'o n _?nter +e%ond number G_ read b

    %O`expr [a 5 [b`

    e%'o _=esult is_ [%%am!le "rogram #

    T +ubtra%t rom 3

    e%'o n _?nter First number G_

    read a

    e%'o n _?nter +e%ond number G_

    read b

    %O`expr [a [b`

    e%'o _=esult is_ [%%am!le "rogram &

    T o "'e%! igger number beteen to numbers

    e%'o n _?nter First number G_

    read a

    e%'o n _?nter +e%ond number G_

    read b

    i [a gt [b J. t'en

    e%'o _3 is I&_

    eli [a eD [b J. t'en

    e%'o _ot' are eDual_

    else

    e%'o _ is I&_

    i%am!le "rogram )

    T o s'o table o number given by user

    iO1

    e%'o n _?nter any number G _

    read n

    'ile [i le 10 J

    do

    e%'o _[n X [i O `expr [i YZ [n`_

    iO`expr [i 1`

    done%am!le "rogram 5

    T"'e%!s to see 'osts 19/#16@#0#1 to 19/#16@#0#10 are alive

    or n in W1##10R. do

    'ostO19/#16@#0#[n

    ping %/ ['ost EP 5dev5null

    19

  • 8/12/2019 Linux 033_

    20/40

    i [ O 0 J. t'en

    T print 'ost names 40 %'ar ide and let $ustiied

    print _S40s is aliveYn_ ['ost

    else

    print _S40s is N* aliveYn_ ['ost

    i done

    U*I$+)%tandard In!ut ' (ut!ut and "i!es

    *ne o t'e most important eatures o Linux (and UNIX) is t'e ability to redire%t a%ommand2s input8 output8 and error data# Linux provides t'e t'ree I5* %'annel to programs#1. %tandard In!ut -eyoard y default

    2. %tandard (ut!ut $erminal ;indows y default

    3. %tandard error $erminal ;indows y default0edirecting to file

    1# P =edire%t +> *UCU to ile/# /P =edire%t +> ?==*= to ile4# EP =edire%t all output to a ile

    Aommon 0edirection o!erators1# "ommand Pilename >ire%t standard output %ommand to ile#/# "ommand PPilename 3ppend standard output %ommand to ile#4# "ommand ilename +end ile as input to %ommand-# "ommand /Pilename =edire%ted error message rom %ommand to ile#B# "ommand /PPilename 3ppend error message rom %ommand to ile#

    1. In!ut 0edirection8+ any text input enter rom t'e !eyboard redire%t in to spe%iiedile# VJ T %at Pilename8 VJ T ls lPilename2. (ut!ut 0edirection8 instru%t to s'ell to redire%t to a %ommand output into t'espe%iied ile instead o t'e terminal# VJ T %at ilename3. :rror 0edirection8 VJ T xy /Perror message

    :x!eriment of u!!er command y the following !rocessFirst o %reate a user on root and login to t'at user and ollo t'e step

    1# VJ T ind 5 name passd/# VJ T ind 5et% name passd4# VJ T Find 5et% name passd Pra$ (ilename) Wsend t'e result in ra$ and s'o

    remaining errorR#-# VJ T %at ra$ (ilename) Wra$ s'o t'e resultR#

    B# VJ T ind 5et% name passd PPra$ (ilename) Wadd t'e result in ra$ 'i%' %omes in%ommand number 4R#

    6# VJ T %at ra$ Ws'o t'e total result in ra$R7# VJ T %at ra$ W%ommand 6 and 7 'as same output e use %ommand as ell as

    %ommand 7R#@# VJ T ind 5et% name passd /Pra$/ (ilename) Wsend t'e errors in ra$/(ilename) and

    s'o resultR#

    /0

  • 8/12/2019 Linux 033_

    21/40

    9# VJ T %at ra$/ (ilename) or VJ T %at ra$/ (ilename) Wto see t'e error are in ra$/(ilename)R#

    10# VJ T ind 5et% name passd /PPra$/ (ilename) Wadd t'e error 'i%' are %omes in%ommand @R#

    11# VJ T %at ra$/ (ilename) or VJ T %at ra$/ (ilename)#1/# VJ T ind 5et% name passd EPra$4 (ilename)#14# VJ T %at ra$4 (ilename)#1-# VJ T ind 5et% name passd Paa Pbb Wto send all t'e result in ile named aa and error

    in ile named bbR#1B# VJ T %at aa Wto see resultR#16# VJ T %at bb Wto see errorR#

    0edirecting %$/(U$ to a "rogram O"i!ingP Cipes (t'e %'ara%ter) %an %onne%t %ommands# (%ommand1 %ommand/)

    +ends +>*U o %ommand1 to +>IN o %ommand/ instead o t'e s%reen#

    +>?== is not orarded a%ross pipes#

    "I":is used to add to or more %ommands# :x VJ T ls l more

    $r translate t'e upper %ase into loer %ase and loer %ase into upper %ase#*riginal ile ill be un%'anged#

    %yntax8+ VJ T tr Ka2 K3]2 ilename%yntax8+ VJ T tr K3]2 Ka2 ilename

    0edirecting %$/(U$ to a "rogram :xam!les Less8 vie input one page at a time# VJT ls l 5et% less Winput %an be sear%'ed it' 5R#

    L!r8+end input to a printer#VJ T e%'o ,test print lpr or VJT e%'o ,test print lpr p printername#

    7ail8 +end input via email#VJ T e%'o ,test mail mails ,test usercexample#%om

    %cri!ting for loo!sCerorming a%tions on ea%' member o a set o values#%yntaxG ma!e a ile it' AI editorTQ5bin5bas'T alive/#s'T %'e%!s to see i 'osts 19/#16@#1#119/#16@#1#/0 are aliveT iterate t'roug' IC addressesFor n in W1/0R. do

    ;ostO19/#16@#1#[nCing %/ ['ost EP 5dev5null

    I [ O0J. t'en

    ?%'o ,['ost is up?lse

    ?%'o ,['ost is donFi

    >one

    Cress K?+"2 !ey

    /1

    mailto:[email protected]:[email protected]
  • 8/12/2019 Linux 033_

    22/40

    G

  • 8/12/2019 Linux 033_

    23/40

    KD cut f3 d8 'etc'!asswd

    paste ,Caste iles toget'erKD !aste file1.txt file2.txt Q file3

    as!ell, ex!and loo and sed as!ell ,o %'e%! spelling in ile , %yntax KD as!ell chec filename ex!and ,?xpand tabs into spa%es

    M expand tabile#txt P result#txt Loo give t'e mat%'es related or! rom dire%tories# %yntax KD loo word

    %ed Ostream editorP use to sear%' and repla%e pattern but original ile ill beun%'anged#

    %yntax KD sed Fs'9i>ay'amitG filename

    KD sed Fs'9i>ay'amitG filename Qnew filename Osa9ing

    changes in another fileP.

    %tring "rocessing with 0egular :x!ressions

    re!, sed, aw, diff gre! 'is %ommand is used to sear%' a ord in a ile# %yntax KD gre! FEAcDat filename

    KD gre! +i FEfDrog filename Oi+ re!resents case

    insensti9ityP

    %yntax KD gre! +3 FcatG filename O stand for afterP

    KD gre! +B3 FcatG filename OB stand for eforP

    , Crints lines o iles 'ere a pattern is mat%'edM gre! amit 'etc'!asswd

    sed , +tream ?ditor G =eads a ile . rites out t'e data perorme sear%' andrepla%e , original ill be un%'anged#

    M sed Fs'ig'small'G somefileM sed Fs'ig'small'gG somefile

    aw , Crogramming language or editing text ,M aw F 'ash' R !rint S F 'etc'!asswd

    diff t'is %ommand is used to ma!e a dieren%e beteen / iles#%yntax KD diff file1 file2

    /4

  • 8/12/2019 Linux 033_

    24/40

    U*I$+

    TI78 n d9anced $ext :ditorTim stand for O9isual im!ro9ed editorP8+ it is a advan%e version o AI editor it %reatet'e text ile in en%rypted orm#%yntax8+ 9im +x filename

    Introduction of TI78+ Neer version o AI t'e standard UNIX text editor#

    1# ?xe%uting AI runs AI: by deault#

    TI7 grap'i%al version o AI:#1# 3ppli%ation Crogramming AI/# Croviding by AI: x 11 Ca%!age

    d9antage of TI78

    +peedG do more it' eer !eystro!es#

    +impli%ityG no dependen%e on mouse5&UI

    3vailabilityG in%luded it' most UNIX li!e uses#/isad9antage of TI78

    >ii%ultyG steeper learning %urve t'an simpler editors#

    \eystro!e be'avior is dependent upon AI:2s modeIn t'is AI: or AI editor you 'ave t'ree mode#1# "ommand modeG (>eault) move %ursor8 %ut8 text8 %'ange mode#/# Insert modeG modiied text#4# ?xmodeG save E Duit et%#

    7o9ing round command mode8

    :ove by ord 8 b

    :ove by senten%e )8 (

    :ove by Caragrap' R8 W

    Hump by line X X& Hump by end line &

    %hortcut of Aommand mode8

    it stand or append to t'e end line#

    I insert at beginning o t'e line#

    o insert a ne line don side#

    ( insert a ne line up side#

    U used or undo

    /-

  • 8/12/2019 Linux 033_

    25/40

    =or mouse8 'let8 $don8 !up8 lrig't#Aommand for word re!lacement8

    VJ T GSs5old ord5ne ord

    7ani!ulating $ext Aommand mode

    ;ord Ahange O0e!laceP /elete OAutP an OAo!yP

    Line AA dd yy

    Letter cl dl yl

    ;ord cw dw yw

    %entence ahead cP dP yP

    %entence ehind cO dO yO

    "aragra!h ao9e cR dR yR

    "aragra!h ehind cS dS yS

    Line wise "aste p used or paste belo t'e line

    C used or paste above t'e line

    Aharacter wise word wise p used or paste ater t'e %ursor

    C used or paste beore t'e %ursor

    /B

  • 8/12/2019 Linux 033_

    26/40

    U*I$+1

    Basic %ystem Aonfiguration $oolsI" ddressing

    Is a 4/bit Logi%al 3ddress 'i%' ma!e %omputer to %ommuni%ate to ea%' ot'ersusing "C5IC proto%ol#

    >eined in dierent %lasses From 3 to ?

    "lass 3O 1 to 1/6

    "lass O 1/@ to 191

    "lass "O 19/ to //4

    ;e can assign I" ddress to com!uter y using two methods1# +tati% :anually J/# >ynami% Using >;"C +erver J

    *etwor Aonfiguration Aommands ifconfig

    Used to vie t'e properties o a%tive and ina%tive netor! intera%es

    ifconfig

    Ifconfig a O to display inormation about ina%tive netor! intera%e

    ifu! ' ifdown

    Used to a%tivating and dea%tivating a netor! intera%e

    ifdown eth

    ifu! eth

    mii+tool

    ool allos a system administrator to vie8 monitor8 log and %'ange t'e negotiatedspeed o ?t'ernet netor! %ards

    mii+tool 9 O to vie t'e %urrent status o netor! intera%e %ard

    mii+tool 9 ++force 1ase$x+=/ eth o %'ange t'e negotiated speed o ?t'ernet netor! %ard

    *etwor Aonfiguration Utilities neat ' neat+tui

    extbased netor! %oniguration tool

    *nly rites %onig iles# >oes not a%tivate devi%e or %'anges# Use iup5idon to a%tive %'anges or restart t'e netor! servi%e

    Used by !udu 'en ne netor! %ard ound at boot time

    /6

  • 8/12/2019 Linux 033_

    27/40

    system+config+networ

    &N*:?based netor! %oniguration tool

    "an be laun%'ed by a nonprivileged user8 but reDuires aut'enti%ation as root#

    "rinting in Linux Crinter may be lo%al or netor!ed#

    Crint reDuests are sending to Dueues#

    ueued $obs are sent to t'e printer on a irst %ome irst serve basis#

    Hobs may be %an%elled beore or during t'e printing#

    L!r command is used to !rint the file.

    %ystem+config+!rinter

    U*I$+11

    In9esting and 7anaging "rocesses

    ;hat is a "rocess)#

    *ptions may be %ombined#to! command 'e %ommand topis used to s'o a realtime vie o Linux tas!s top%an be used to display t'e "CU5memory usage o ea%' tas! to!

    $erminate "rocesses kiis used to terminate pro%esses or to send signal to pro%esses# ?xamplesG

    M ill "I/M erminate t'e pro%ess it' t'e pro%ess id (CI>)#

    /7

  • 8/12/2019 Linux 033_

    28/40

    U*I$+12Aonfiguring the Bash %hell

    ;hat is Bash %hell

  • 8/12/2019 Linux 033_

    29/40

    U*I$+13=inding and "rocessing =iles

    Locate8+

    ueries a prebuilt database o pat's o iles on t'e system#/# >atabase must be updated by administrator#4# Full pat' is sear%'ed8 not $ust ile name#

    :ay only sear%' dire%tories 'ere t'e user 'as read and exe%ute permission#*ote8+ Lo%ate %ommand is used to sear%' t'e ull pat' o ile8 and display i lo%ate%ommand does not run t'en irstly run Kupdatedb2 %ommand at root login ater t'at run,Lo%ate %ommand# %yntax8+VJ T lo%ate dirnameslocate and find slo%ate , +ear%' or iles ,

    M slocate somefile ind , +ear%' or iles ,

    M find 'home name somefileM find 'home iname somefile E case+insensiti9e search DM find 'home user amit grou! amit somefileM find 'home !erm )##M find 'home si@e 1M find 'home user usernameM find 'home user username o user username

    =ind ccess $ime

    1# atime 'en ile as last read#/# %time 'en ile data as last %'anged#4# mtime 'en ile data or metadata last %'anged#

    %yntax8+VJ T ind %time day2s no#(ile modiied less t'en 10 days ago#)

    VJ T ind atime B(loo!s or iles 'ose last a%%ess time stamp exa%t B days ago#

    VJ T ind atime B(loo!s or ile 'ose last a%%ess time stamp is more t'en B days ago#

    =ind "ermission

    "an mat%' oners'ip by name or I>#1# VJ T ind 5'ome user username o uid B00

    /9

  • 8/12/2019 Linux 033_

    30/40

    "an mat%' o%tal or symboli% permissions#1# VJ T ind prem 7BB (mat%'es i mode is exa%t)/# VJ T ind prem /// (mat%'es i anyone %an rite)4# VJ T ind prem /// (mat%'es i everyone %an rite)

    =ind *umeric Ariteria8

    :any ind %riteria ta!e numeri% values

    VJ T ind sie 10/-!b1# Files it' a sie o exa%tly 1 megabyte#

    VJ T ind sie 10/-!b1# Files it' a sie over 1 megabyte#

    VJ T ind sie 10/-!b1# Files it' a sie less t'en 1 megabyte#

    U*I$+14

    *etwor Alients=irefox Fast8 lig'teig't8 Featureri%' eb broser#

    abbed brosing#

    Copup brosing#

    "oo!ie management#

    :ultiengine sear%' bar#

    +upport or many popular plugin#

    'emes and ?xtension#

    :lins est linux textbased eb %lient ( eb broser )

    Full support or rames and ++L 'ttps ebsites J

    ?xampleG

    VJ T elin!s 'ttpG55#red'at#%om#

    >onload manager

    oo!mar!

    wget =etrieves iles via ;C and FC

    Nonintera%tive useul in s'ell s%ripts

    "an ollo lin!s and traverse dire%tory trees on t'e remote server

    ?xample

    wget htt!8''www.download.com'songs!layer'm!layer.exe

    aim :ultiproto%ol Instant messaging %lient

    +upports 3I:8 :+N8 3;**8 I"8 Habber8 &adu&adu8 +IL"8 &roup

  • 8/12/2019 Linux 033_

    31/40

    &rap'i%al FC "lient

    3llos >ragand>rop ransers

    *ptional se%ure transer via ss' ( stp )

    :9olution >eault ?mail "lient sotare

    "an maintain multiple a%%ounts and on%e

    mutt ext based ?mail %lient

    +upports C*C8 I:3C and Lo%al mail boxes

    :appable 'ot !eys#

    ssh8 %ecure %hell ss' allos remote logins and remote %ommand exe%ution via a se%ure en%rypted

    %onne%tion#

    +e%ure repla%ement or older remotea%%ess tools#

    3llos aut'enti%ated8 en%rypted a%%ess to remote systems

    ?xample ssh rootVstation1.exam!le.com

    sc!8 %ecure Ao!y s%p or!s li!e %p8 ex%ept it %opies rom one 'ost to anot'er in a se%ure en%rypted

    %'annel

    ?xample

    sc! somefile rootVstation1.exam!le.com8

    resync8?i%iently ile syn% ?i%iently "opies iles to or rom remote systems#

    Users se%ure ss' %onne%tion or transport#

    Faster t'an s%p# %yntax

    VJ T rsyn% sour%e destination add#

    VJ T ss' rootcipaddress

    VJ T s%p rootcipaddress8'root'dirname 'root

    VJ T rsyn% rootcipaddress8 'root'dirname 'root

    Introduction to %hell %cri!ting;hat is shell scri!t < +'ell s%ripts are text iles t'at %ontains a series o %ommands or statements to be

    exe%uted

    +'ell s%ripts are useul or

    3utomating %ommonly used %ommands

    Cerorming system administration and troubles'ooting

    "reating simple appli%ations

    Areating %hell %cri!ts "reate a ile using vi text editor

    41

  • 8/12/2019 Linux 033_

    32/40

    Use T or %omments Inormation J

    ?nter %ommands related to s%ripts

    :a!e t'e s%ript exe%utable

    chmod aCx scri!tWname

    o ?xe%ute t'e ne s%ript

    Cla%e t'e s%ript in a dire%tory in t'e exe%utable pat' *r +pe%iy t'e absolute or relative pat' to t'e s%ript on t'e %ommand line

    :xit %tatus ?very %ommand returns an exit status# 'e exit status ill be a number in t'e

    range o 0 to /BB and it indi%ates 'et'er or not t'e %ommand ran su%%essully#

    0 or su%%ess8 1 to /BB or ailure

    ?xit status o most re%ently exe%uted %ommand is !ept in t'e [ Aariable $ust li!ereturn values rom s'ell un%tions

    ?xampleG

    echo J and a &I>#

    ?very pro%ess runs as a UI> and one or more &I>2s# usually determined by 'o runst'e pro%ess#

    'ree a%%ess %ategories#

    Cro%ess running it' t'e same UI> as t'e ile (user)#

    Cro%ess running it' t'e same &I> as t'e ile (group)#

    3ll ot'er pro%ess (ot'er)#

    ;hat is "ermission < +pe%iies 'at rig'ts are you granting to users to a%%ess t'e resour%es are available in

    t'e %omputer8 so t'at important resour%es su%' as iles are prote%ted romunaut'oried users#

    44

  • 8/12/2019 Linux 033_

    34/40

    7ethods of Im!lementing "ermissions +ymboli% :et'od Numeri% :et'od

    !!lying "ermission with *umeric 7ethod-# - (or read)B# / (or rite)6# 1 (or exe%ute)

    :xam!le8 + KD %'mod 6-0 ile name

    I u ants to give t'e read8 rite8 permission to oner t'en %ombined t'ebot' digit %ode (-/O6)8 and read permission to group (-)8 and or ot'er2s onpermission t'en (0)#chmod%ommand is used to %'ange a%%ess modes

    Numeri% :et'od

    M chmod &&4 somefileile name

    (&rants =ead and eault permission or iles is 666 >eault permission or dire%tories is 777 /efault "ermission Umas M :ffecti9e "ermission

    M NonCrivileged Users umasis 00/

    Files ill 'ave permissions o 66-

    >ire%tories ill 'ave permission o 77BM root2s umas! is 0//M ?xample G

    M 666 00/ O &&4M 666 /-- O 422M 777 /// O ###M 777 0/7 O )#

    4-

  • 8/12/2019 Linux 033_

    35/40

    %!ecial "ermission for directories8 %ticy it8t'e sti%!y bit or a dire%tory sets a spe%ial restri%tion on deletion o

    ilesG it' t'e sti%!y bit set8 only t'e oner o t'e ile and super user (root) %an

    delete iles it'in t'e dire%tory# +ti%!y bit is (1):xam!le VJ T %'mod 1777 dirname

    %gid8iles %reated in dire%tories it' t'e sgid bit set 'ave group ailiations o t'egroup t'e dire%tory# (/) :xam!le

    VJ T %'mod /770 dirname

    (ften oth the sti%!y bit and sgid permission ill be set on a group dire%tory#:xam!le

    Others do not have write-

    Others have readr

    Group has executex

    Group does not have write-

    Group has readr

    Owner has executex

    Owner has writew

    Others have execute

    Owner has readr

    x

    Permissions

    4B

  • 8/12/2019 Linux 033_

    36/40

    VJ T %'mod 4770 dirname

    :xam!le

    VJ T %'mod -BB1 passd

    U*I$+1&

    $he Linux =ile system in+/e!thBasic =ile %ystem $y!es 3 ile system is t'e logi%al stru%ture and sotare routines t'at %ontrol a%%ess to t'e

    storage spa%e on dis!s#

    Unli!e most operating systems8 Linux supports several ile system types#

    'e ?xt/ (+e%ond ?xtended) ile system is t'e most %ommon Linux ile system and ist'e se%ond version o t'e ?xt ile system

    'e ?xt/ ile system as designed to over%ome dei%ien%ies ound in t'e ?xt ilesystem

    'e ?xt ile system %an 'andle partitions up to / gigabytes (&) in sie8 'ereas

    ?xt/ %an 'andle partitions up to - terabytes () in sie=eatures of :xt2 'e ?xt/ ile system 'as many ot'er advan%ed eatures in%luding provision or

    ilenames up to /BB %'ara%ters long

    ?xt/ also reserves dis! spa%e on t'e partition or t'e superuser# 'is means t'at i adis! develops a problem8 t'e superuser %an still a%%ess t'at dis! and re%tiy it

    :xt3 file system In Linux 7#/8 ext/ is t'e deault ile system

    =eDuire %'e%! or %onsisten%y (e/s%!) 'en system is not properly s'utdon

    ?xt OP ext/ OPext4

    +upport /B6 %'ar ilenames8 - era byte max ilesie *t'ers :+>os8 F34/8 NF+8 I+*9660

    +tarting rom Linux 7#48 ext4 is t'e deault ile system

    Crovide stronger data integrity in event o un%lean s'utdon

    "'e%! or %onsisten%y is needed only on rare 'ardare ailure

    ;ig'er t'roug'put8 as it is optimies 'ard drive 'ead motion

    Crovide easy transition rom ext/ to ext4

    46

  • 8/12/2019 Linux 033_

    37/40

    ot'er %ommon ilesystem are :+>*+ (F34/8 NF+8 I+*9660)

    'e ext4 ile system is essentially an en'an%ed version o t'e ext/ ile system#3dvantages areG

    9ailaility 3ter an poer ailure or system %ras' (also %alled an unclean system

    shutdown)8 ea%' mounted ext/ ile system on t'e ma%'ine must be %'e%!edor %onsisten%y by t'e e2fscprogram# 'is is a time%onsuming pro%ess t'at%an delay system boot time signii%antly8 espe%ially it' large volumes#

    'e $ournaling provided by t'e ext4 ile system means t'at t'is sort o ilesystem %'e%! is no longer ne%essary ater an un%lean system s'utdon# 'eonly time a %onsisten%y %'e%! o%%urs using ext4 is in %ertain rare 'ardareailure %ases8 su%' as 'ard drive ailures#

    /ata Integrity 'e ext4 ile system prevents loss o data integrity in t'e event t'at an

    un%lean system s'utdon o%%urs# 'e ext4 ile system allos you to %'ooset'e type and level o prote%tion t'at your data re%eives#

    "artition and =ile %ystem >is! drives are divided into partitions Cartition are ormatted it' ile system8 allos users to store data

    M >eault ile systemG ext48 t'e 'ird ?xtended Linux File +ystemM *t'er %ommon ile systemsG

    M ext/ and vatM iso9660 ( typi%ally used or ">s)

    Lins 3 lin! is a ile t'at points to anot'er ile# ,ln %reates a ,lin! rom t'e original ile to a ne ,ile in your dire%tory# :ost programs ill a%%ess t'e lin! as i it as t'e ile# 'is is similar to a ,s'ort%ut in

  • 8/12/2019 Linux 033_

    38/40

    mount 'media'flo!!y O :ounts loppy drive to your %omputermount 'media'cdrom O :ounts %drom drive to your %omputermount 'media'/e9ice I/ O :ounts usb dis! to your %omputer

    "ommands to unmount media

    umount 'media'flo!!y O Unmounts loppy drive to your %omputerumount 'media'cdrom O Unmounts %drom drive to your %omputerumount 'media'/e9ice I/ O Unmounts usb dis! to your %omputer

    rchi9e =iles 3r%'iving pla%es many iles into one target ile ?asier to ba%! up8 store8 and transer tar +tandard Linux ar%'iving %ommand

    Using rchi9e files tar command

    tar c9f archi9eWname files..( o %reate ar%'ive ile ) tar t9f archi9eWname files..

    ( o display iles under ar%'ive ile ) tar x9f archi9eWname files..

    ( o extra%t iles rom ar%'ive ile ) tar r9f archi9eWname files..

    ( o append ar%'ive ile )

    =ile Aom!ression =esults in smaller ile sie ext iles %an be %ompressed over 7BS tar ar%'ives are oten %ompressed

    Aom!ression Utilities g@i!, gun@i!

    M +tandard Linux %ompression utilityM Up to 7BS %ompression or text iles

    @i!2, un@i!2

    M Neer Linux %ompression utilityM &enerally a%'ieves better %ompression t'an gip

    Using Aom!ression

    g@i! somefile( o %reate %ompressed ile )

    gun@i! somefile

    ( o un%ompress a %ompressed ile ) @i!2 somefile

    ( o %reate %ompressed ile ) un@i!2 somefile

    ( o un%ompress a %ompressed ile )

    4@

  • 8/12/2019 Linux 033_

    39/40

    *oteG for @i!2type o %ompression it' tar

    U*I$+1)

    :ssential %ystem dministration $ools

    0ed Hat "acage 7anager um %er9er0"78+'e =C: Ca%!age manager greatly simpliies t'e distribution8 installation8upgrading8 and removal o sotare on =ed ;at ?nterprise Linux +ystem#

    'e lo%al =C: database is maintained in 5var5lib5rpm# 'e database stores

    inormation about installed pa%!ages su%' as ile attributes and pa%!ages prereDuisites#r!mis a ba%!end or ot'er programs su%' as yumor system+config+!acages. 'e toolsprovide signii%ant advantages su%' as automati% dependen%y resolution#

    "rimary 0"7 o!tions8+ rpm I ilename (or install)

    rpm U ilename (upgrade)

    rpm F ilename (or res'en)

    rpm e ilename (or erase)

    rpm iv' ilename (or update)

    (ut!ut (!tion8+

    +9 OUsed or print pa%!age nameP

    +h OUsed or print 'as' mar!sP

    0"7 Xueries8+=C: provide robust Duerying8 'i%' is invo!ed it' r!m +N orr!mNuery. uery option all into one o to %ategoriesG t'ose t'at spe%iy 'i%'

    49

  • 8/12/2019 Linux 033_

    40/40

    pa%!ages to Duery8 and t'ose t'at spe%iy 'at inormation to retrieve# 'e irst must bespe%iied. t'e se%ond deaults to t'e pa%!age name#

    %yntax8 + r!m +Na Yless r!m +Nf filename Os'o oning pa%!ageP r!m +Ni !acageWname OgeneralinormationP

    r!m +Nl !acageWname Olists iles in pa%!ageP

    0"7 Terification8+veriying an installed pa%!age %ompares t'e ile sies8permission8 type8 oner8 group8 :>B %'e%!sum8 and modiy time against t'e =C:database# 3ny in%onsisten%y ill be reported# 3n installed pa%!age %an also be veriiedagainst a pa%!age ile as ellG

    %yntax8 + r!m +T @i! veriies t'e installed ip rpm against t'e =C:database#

    r!m +Ta veriies all installed =C:+ against t'e =C:database#

    r!m +T! @i!+2.3+5.i35&.r!m veriies t'e installed ip pa%!age

    against t'e ip pa%a!age ile#