Linux 033
Linux 033
Linux 033
and "ermission
#. Using $he Bash %hell &. %tandard In!ut ' (ut!ut and "i!es ). $ext "rocessing $ool
U*I$+1
Idea and History of Linux
First Linux version (UNIX) operating system developed by ,-en $hom!son. and ,/ennis 0itchie in ,1$ 2$ Bells La3 U.%.1. in 1970 or! on "UI mode# 1454 *U pro$e%t as introdu%ed (&rap'i%al Not UNIX) it as an organi(ation t'e aim o) t'is organi(ation to develop t'e %lone o) U*I6 *perating +ystem# 145) 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 0oday used on 7110 million %omputers it' 10002s o) programmers or!ing to en'an%e it
;hat is -ernel<
0'e !ernel is t'e 'eart o) t'e 'ole operating system# It manages %ommuni%ation it' 'ard are8 de%ides 'i%' pro%esses to run8 and provides ea%' pro%ess it' an isolated8 virtual address spa%e in 'i%' to run# 0'e !ernel is 'at your boot loader8 &=U7 8 loads into memory# 0'e !ernel loads devi%e driver modules
7ulti+tasBing8+ :ultiple tas! %an run pro%ess one by one at a time# 7ulti+!rocessing8+ :ultiple Crograms %an per)orm at a time
"rinci!le of Linux
1. :9erything is a file8+ 0'e UNIX se%urity module is based around t'e se%urity o) )iles by treating everyt'ing is a )ile# Fou %an se%ure a%%ess to ;ard are in t'e same ay as you se%ure a%%ess to do%ument# 2. %mall, %ingle !ur!ose !rogram81 UNIX provide many small utility t'at per)orms one tas! very ell# 3. 13ility to chain !rograms together to !erform com!lex tasB8 1 3 %ore design )eature o) UNIX is t'at t'e output o) one programs %an be input )or anot'er# 4. 19oid ca!ti9e user interface81 Intera%tive %ommands are rare in UNIX more %ommands expe%t t'eir options and arguments to be typed on t'e %ommand line 'en t'e %ommand line is laun%'ed# 0'e %ommand %omplete normally8 possibly produ%ing output or generate an error message and Duits inter1a%tivity is reserved )or programs 'ere it ma!e sense #. Aonfiguration data stored in text8+ all t'e data is stored in text b2%o( text is Universal inter)a%e and many UNIX utility exist to manipulate text# +toring "on)iguration in text allo s an administrator to move a "on)iguration )rom one :a%'ine to anot'er easily#
;hat is ;I*/(;%< ;+ I+ *+ /+ (+ ;+ %+ <ide Intera%tive Net or! >evelopment *))i%e <or! +olutions
1# =ed 'at /# +use 4# 0urbo Linux -# Fedora Linux B# +ol +upported by =;?L +upported by N*A?LL +upported by U+ E Hapenese +upported by =?> ;30 +upported by +erver *ptimi(ed Linux
/istri3utors of Linux
:nd of U*I$+1
U*I$+ 2
Linux Usage Basic
Login in to a Linux %ystem8+ =ed ;at Linux provide t o type o) login met'od# 0 o type o) login +%reen G1 Airtual "onsole Itext basedJ and &rap'i%al Login Idisplay managerJ Login using login name and pass ord# ?a%' user 'as a 'ome dire%tory )or personal )ile storage# =ed ;at provides by de)ault six virtual %onsoles t'at are I ctrlCaltCf1D to EctrlCaltCf&D. EctrlCaltCf)D is used )or &rap'i%al mode# Init & and re3oot %ommand is used to restart# :lements of F6G ;indows %ystem8+ 0'e KX2 <indo s system is Linux2s &rap'i%al subsystem ,XL *rg# is parti%ular version o) t'e X indo s system used by =ed ;at# Loo! E 7e'avior Largely "ontrolled by t'e >es!top ?nvirment# 0 o >es!top environments provided by =ed ;at# 1111# *(7: t'e de)ault
%im!le 9iew of
*(7: /esBto!
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 (N?nterP O ma!e %urrent line )irst line on s%reen (1 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 QR)mt 166 O )ormats t'e data o) your )ile in to 66 %olumn idt' ?x mode G +ear%' and =epla%e %ommand GSs5big5small GSs5big5small5g 0o display t'e list o) )iles E >ire%tories e use ,lsL %ommand# 7lue "olor ,>ire%toriesL and <'ite "olor )iles# I it s'o s t'at login it' Crivilege User J it s'o s t'at login it' Non1 Crivilege user History %ommand is used to s'o t'e past %ommand# 0e3oot, init &, %ommand is used to restart t'e system# "ower off "ommand is used to s'utdo n t'e system . If you ant your system s'ut do n a)ter your parti%ular time li!e a)ter / minute t'en %ommand is J T s'utdo n U' / I 1' )or 'alt8 / )or / minuteJ Areating directory8+ J T m!dir dir name :ntering into dir8+ J T %d dir name
10
:nd of U*I$+2
Unit+4
Browsing the file system
<e 'ave already dis%ussed or learned in UNIX all8 in)ormation treated as a )ile# +ingle dis! %an store t'ousands o) )iles or organi(ing t'e data on t'e dis! t'e o5s provides a )ile system# 0'ere are t'ree types o) )ile# 1. (rdinary 2 0egular file8+ all )iles are %reated by a user %ome under t'ese %ategories# 2. /irectory file8+ )or ea%' dire%tory t'ere is )ile by t'e same name as t'e dire%tory# <'i%' %ontain in)ormation about )iles under t'at dire%toryX 3. /e9ice file81 devi%e )ile are spe%ial types typi%ally asso%iated it' input5output devi%e su%' as Crinter8 0ap >rive8 ;>>8 F>>8 ">1>rive#
1. '3in8+ t'is is t'e binary dire%tory# <'i%' %ontain t'e exe%utable )ilesX <'en a program is installed its binary )iles are stored 'ere# 2. 'de981 dev stand )or devi%e t'at %ontains )iles t'at point to t'e 'ard are t'at ma!e up t'e system# 3. 'etc81 t'is )older %ontains various %on)iguration )iles t'at %an be manually edited to a))e%t t'e system %'arge# 4. 'li381 lib means ,LibraryL )iles )reDuently used system )iles needed by program or t'e operating system are stored 'ere $ust li!e library )iles stored in ,"GY indo sYsystemL in indo s o5s# #. 'usr8+ Non1%riti%al )iles are stored in t'is dire%tory 'i%' %ontain a %opy o) most o) t'e dire%tories in t'e root# &. '9ar81 t'e various )older %ontains $ust t'at various )iles su%' as log )ile# ). 'tem81 t'is is t'e dire%tory t'at used by appli%ation )or storing temporary )iles# 5. 'o!t81 t'e option dire%tory stored add on %omponent su%' as des!top envoirment database # 4. 'mnt81 all storage media ot'er t'an Linux partition are mounted 'ere# 1L. 'root81 t'is is t'e 'ome dire%tory o) t'e root user 11. '3oot81 t'e boot loader )iles are stored 'ere# 12. 'home81 t'is is t'e dire%tory t'at %ontain user2s )ile#
11
13. $he '!roc' /irectory + %ontains spe%ial )iles t'at eit'er extra%t in)ormation )rom or send in)ormation to t'e !ernel# ?xamples in%lude system memory8 %pu in)ormation8 'ard are %on)iguration et%# 14. $he 's3in' /irectory + stores exe%utables used by t'e root user# 0'e exe%utables in 5sbin5 are used at boot time8 )or system administration and to per)orm system re%overy operations#
:nd of U*I$+4
1/
Unit+#
User, rou!, and "ermission ;hat is User 1ccount <
<'en a %omputer is used by many people it is usually ne%essary to di))erentiate bet een t'e users8 )or example8 so t'at t'eir private )iles %an be !ept private# 0'is is important even i) t'e %omputer %an only be used by a single person at a time8 as it' most %omputers# 0'us8 ea%' user is given a uniDue username8 and t'at name is used to log in#
User8+
?very user is assigned a uniDue user I> no# (UI>)# (UI>0) identi)y root# User2s name and UI> are stored in 5et%5pass d# 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# *ote to see UI> run t'e VJ T "at 5et%5pass d#
;hat is
rou! <
Is a %olle%tion o) users 'i%' ma!e easy )or administrators to per)orm t'e tas! o) administration level 'en t'ey need to apply permissions and restri%tions it' same level to many o) t'e users8 t'en su%' permission and restri%tions %an be applied to related 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 o n private group# "an be added to ot'er groups )or additional 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
14
"ermission $y!es
"ermissions+ %ym3olic 7ethod
Four 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 long listing o) t'e dire%tory# +G 1 no permission in pla%e o) t'e r8 8 x#
:xamining "ermission
File permission may be vie ed using VJ [ ls Ul 5bin5login 1r xr1xr1xl root root 190@0 3pr 1 1@G/6 5bin5login File type and permissions are represented by a 10 %'ara%ter string#
1-
:nd of U*I$+#
1B
Unit+&
Using the 3ash 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 use)ul )or 3utomating %ommonly used %ommands Cer)orming system administration and troubles'ooting "reating simple appli%ations :anipulation o) text or )iles# +'ell ma!es an inter)a%e bet een Users E \ernel# 0'ere are t'ree main s'ells )or UNIX isG 1 1. Bourn %hell 2. A %hell 3. -orn %hell No a days 7as' s'ell be%ome popular in Linux *5+# 7roun again s'ell (7as' s'ell) as released Brain fox 2 chief 0emey as part o) t'e )ree so)t are )oundation# 0'e *U pro$e%t )eatures o) 7as' s'ell areG 1 1# Input and output redire%tion# /# Use o) ild %ard# 4# "ommand line editing# -# ]ilde representation B# 7uilt1 in s'ell %ommand E Aariables# 6# "ommand 'istory and aliasing#
*otes8 +
+yntaxG 1 VJ T Q %'ar ?xampleG 1 VJ T Q d (any %'ara%ter alp'abate) Q num repeat last %ommand by t'is no# in 'istory output# +yntaxG 1 VJ T Q num ?xampleG 1 VJ T QB VJ T m!dir UC or!5Winbox8outbox8pendingR5Wnormal8urgent8importantR In3ox *ormal Urgent Im! ;orB (ut3ox *ormal Urgent Im! "ending *ormal Urgent Im!
$o AhecB $his8 +
VJ T ls 0'en it s'o s ( or! dire%tory) VJ T %d or! <or!J T ls 0'en it s'o s (inbox8 outbox8 pending dire%tory) VJ T %d inbox InboxJ T ls 0'en it s'o s (normal8 urgent8 important sub dire%tory)
*(7: $erminal
3ppli%ation 1111 3%%essories 1111 0erminal &rap'i%al terminal emulator t'at supply multiple ,tabbedL s'ells# "trl 9 +'i)t 9 0 "trl 9 Cgup5Cgdn "trl 9 +'i)t 9 < "trl 9 +'i)t 9 " "trl 9 +'i)t 9 A %reate a ne tab# + it%' to next5previous %lose t'e tab# %opies sele%ted text# paste text to t'e prompt
17
7aBe a %cri!t
*pen a ne )ile it' KAI2 editor li!e VJ T vi )ilename and type t'e )ollo ing VJ T vi )ilename Cress ,IL )or insert mode# T Q5bin5bas' T t'is s%ript display ?%'o ,t'e date E time are [ (date)L ?%'o ,your or!ing dire%tory is [ (p d)L ?%'o ,your )iles E >ir# 3re [ (ls 1a) ?%'o ,your virtual %onsoles open are [ ( 'o) Cress ,:%AL !ey 8wN 0o run t'e )ile VJ T .'filename %te! 28+ :a!e t'e s%ript exe%utable VJ T %'mod u9x )ilename 0o 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%i)ying t'e absolute or relative pat' to t'e s%ript on t'e %ommand line#
1@
e%'o _=esult is_ [% %am!le "rogram 4 T >ivides 3 )rom 7 e%'o 1n _?nter First number G_ read a e%'o 1n _?nter +e%ond number G_ read b %O`expr [a 5 [b` e%'o _=esult is_ [% %am!le "rogram # T +ubtra%t 7 )rom 3 e%'o 1n _?nter First number G_ read a e%'o 1n _?nter +e%ond number G_ read b %O`expr [a 1 [b` e%'o _=esult is_ [% %am!le "rogram & T 0o "'e%! 7igger number bet een t o numbers e%'o 1n _?nter First number G_ read a e%'o 1n _?nter +e%ond number G_ read b i) I [a 1gt [b J. t'en e%'o _3 is 7I&_ eli) I [a 1eD [b J. t'en e%'o _7ot' are eDual_ else e%'o _7 is 7I&_ )i %am!le "rogram ) T 0o s'o table o) number given by user iO1 e%'o 1n _?nter any number G _ read n 'ile I [i 1le 10 J do e%'o _[n X [i O `expr [i YZ [n`_ iO`expr [i 9 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 1%/ ['ost EP 5dev5null
19
done
i) I [X O 0 J. t'en T print 'ost names 40 %'ar ide and le)t $usti)ied print) _S140s is aliveYn_ ['ost else print) _S140s is N*0 aliveYn_ ['ost )i
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 -ey3oard 3y default 2. %tandard (ut!ut $erminal ;indows 3y default 3. %tandard error $erminal ;indows 3y default
0edirecting to file
1# P /# /P 4# EP =edire%t +0> *U0CU0 to )ile =edire%t +0> ?==*= to )ile =edire%t all output to a )ile
/0
9# VJ T %at ra$/ ()ilename) or VJ T %at Nra$/ ()ilename) Wto see t'e error are in ra$/ ()ilename)R# 10# VJ T )ind 5et% Uname pass d /PPra$/ ()ilename) Wadd t'e error 'i%' are %omes in %ommand @R# 11# VJ T %at ra$/ ()ilename) or VJ T %at Nra$/ ()ilename)# 1/# VJ T )ind 5et% Uname pass d EPra$4 ()ilename)# 14# VJ T %at ra$4 ()ilename)# 1-# VJ T )ind 5et% Uname pass d 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#
/1
VJ T# 5ra$ ()ilename)#
=ilter Aommand
VJ T grep# 5et%5pass d Wit s'o t'e %ontent o) )ile a)ter )ilteringR#
%ort Aommand
VJ T sort %olor (it s'o t'e alp'abeti%al %ontent)# VJ T ls Ul asort 7utt Aommand Ot'is %ommand is a text1based mail %lientP.
KD I cut Hf3 Hd8 'etc'!asswd paste ,Caste )iles toget'erL KD I !aste file1.txt file2.txt Q file3
as!ell, ex!and looB and sed as!ell ,0o %'e%! spelling in )ile , %yntax KD I as!ell checB filename ex!and ,?xpand tabs into spa%esL M expand tab)ile#txt P result#txt LooB give t'e mat%'es related or! )rom dire%tories# %yntax KD I looB word %ed Ostream editorP use to sear%' and repla%e pattern but original )ile ill be un%'anged# %yntax KD I sed Fs'9i>ay'amitG filename KD I sed Fs'9i>ay'amitG filename Qnew filename Osa9ing changes in another fileP.
/4
=or mouse8 '1le)t8 $1do n8 !1up8 l1rig't# Aommand for word re!lacement8 VJ T GSs5old ord5ne ord
/B
system+config+networB &N*:?1based net or! %on)iguration tool "an be laun%'ed by a non1privileged user8 but reDuires aut'enti%ation as root#
"rinting in Linux
Crinter may be lo%al or net or!ed# Crint reDuests are sending to Dueues# eueued $obs are sent to t'e printer on a )irst %ome )irst serve basis# Hobs may be %an%elled be)ore or during t'e printing# L!r command is used to !rint the file. %ystem+config+!rinter
!s command
0'e %ommand ps is used to determine t'e status o) a%tive pro%esses# 0'e %ommand returns t'e pro%ess id (CI>) number and ot'er in)ormation su%' as t'e amount o) "CU time t'e pro%ess 'as used (0I:?) and t'e %ommand 'i%' invo!ed t'e pro%ess (":>)# *ptions may be %ombined#
to! command
0'e %ommand top is used to s'o a real1time vie o) Linux tas!s top %an be used to display t'e "CU5memory usage o) ea%' tas! to!
$erminate "rocesses
ki is used to terminate pro%esses or to send signal to pro%esses# ?xamplesG M Bill "I/ M 0erminate t'e pro%ess it' t'e pro%ess id (CI>)#
/7
U*I$+12
Aonfiguring the Bash %hell
;hat is Bash %hell< It is t'e de)ault s'ell )or Linux operating system it as introdu%ed in 197B#
3liasesG1
3liases let you %reate s'ort%uts to %ommands# Use alias by it sel) to see all set aliases# Use alias )ollo ed by an alias name to see alias value#
/@
U*I$+13
=inding and "rocessing =iles
Locate8+ eueries a pre1built 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 a)ter t'at run ,Lo%ateL %ommand# %yntax8+ VJ T lo%ate dirname slocate and find slo%ate , +ear%' )or )iles , M slocate somefile )ind , +ear%' )or )iles , M find 'home Hname somefile M find 'home Hiname somefile E case+insensiti9e search D M find 'home Huser amit Hgrou! amit somefile M find 'home H!erm )## M find 'home Hsi@e 1LLLB3 M find 'home Huser username M find 'home Huser username Ho Huser username =ind 21ccess $ime 1# Uatime 'en )ile as last read# /# U%time 'en )ile data as last %'anged# 4# Umtime 'en )ile data or metadata last %'anged# %yntax8+ VJ T )ind U%time day2s no# ()ile modi)ied less t'en 10 days ago#) VJ T )ind Uatime B (loo!s )or )iles 'ose last a%%ess time stamp exa%t B days ago# VJ T )ind Uatime 9B (loo!s )or )ile 'ose last a%%ess time stamp is more t'en B days ago# =ind 2 "ermission "an mat%' o ners'ip by name or I># 1# VJ T )ind 5'ome Uuser username 1o 1uid B00
/9
"an mat%' o%tal or symboli% permissions# 1# VJ T )ind 1prem 97BB (mat%'es i) mode is exa%t) /# VJ T )ind 1prem 9/// (mat%'es i) anyone %an rite) 4# VJ T )ind 1prem 1/// (mat%'es i) everyone %an rite) =ind 2 *umeric Ariteria8 :any )ind %riteria ta!e numeri% values VJ T )ind 1si(e 10/-!b 1# Files it' a si(e o) exa%tly 1 megabyte# VJ T )ind 1si(e 910/-!b 1# Files it' a si(e over 1 megabyte# VJ T )ind 1si(e 110/-!b 1# Files it' a si(e less t'en 1 megabyte#
:linBs
7est linux text1based eb %lient ( eb bro ser ) Full support )or )rames and ++L I 'ttps ebsites J ?xampleG VJ T elin!s 'ttpG55 #red'at#%om# >o nload manager 7oo!mar!
wget
=etrieves )iles via ;00C and F0C Non1intera%tive1 use)ul 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
:ulti1proto%ol Instant messaging %lient +upports 3I:8 :+N8 F3;**8 I"e8 Habber8 &adu1&adu8 +IL"8 &roup<ise :essenger8 I=" and ]ep'yr net or!s Clugins %an be used to add )un%tionality
g=$"
3ppli%ations5Internet5gF0C
40
&rap'i%al F0C "lient 3llo s >rag1and1>rop 0rans)ers *ptional se%ure trans)er via ss' ( s)tp )
:9olution
>e)ault ?mail "lient so)t are "an maintain multiple a%%ounts and on%e
mutt
0ext based ?mail %lient +upports C*C8 I:3C and Lo%al mail boxes :appable 'ot !eys#
Use T )or %omments I In)ormation J ?nter %ommands related to s%ripts :a!e t'e s%ript exe%utable chmod aCx scri!tWname 0o ?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%i)y t'e absolute or relative pat' to t'e s%ript on t'e %ommand line
:xit %tatus
?very %ommand returns an exit status# 0'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%%ess)ully# 0 )or su%%ess8 1 to /BB )or )ailure ?xit status o) most re%ently exe%uted %ommand is !ept in t'e [X Aariable $ust li!e return values )rom s'ell )un%tions ?xampleG1 echo J<
rou! and
<'en a %omputer is used by many people it is usually ne%essary to di))erentiate bet een t'e users8 )or example8 so t'at t'eir private )iles %an be !ept private# 0'is is important even i) t'e %omputer %an only be used by a single person at a time8 as it' most %omputers# 0'us8 ea%' user is given a uniDue username8 and t'at name is used to log in#
;hat is
rou! <
Is a %olle%tion o) users 'i%' ma!e easy )or administrators to per)orm t'e tas! o) administration level 'en t'ey need to apply permissions and restri%tions it' same level to many o) t'e users8 t'en su%' permission and restri%tions %an be applied to related group#
Areating Users useradd options user 1 "reates a ne user# M 1% 3ssigns )ull name to user#
4/
Uses to de)ine 'ome )olders lo%ation# Uses to de)ine userfs s'ell# (Use 5sbin5nologin )or users you is' to restri%t )rom 'aving s'ell a%%ess)# M 1g 3dd user to group ( Crimary &roup ) M 1& 3dd user to group ( +e%ondary &roup ) usermod options user 1 :odi)ies user a%%ount M +ame options as useradd. userdel options user 1 >eletes user a%%ount# M 1r G =emove userfs 'ome dire%tory# pass d user 1 "'anges t'e pass ord o) t'e spe%i)ied user# M I) no user is spe%i)ied8 ill %'ange t'e pass ord o) t'e %urrent user#
M 1d M 1s
Aonfiguration =iles
5et%5pass d 5et%5s'ado 5et%5group 5et%5gs'ado O O O O )ile %ontains user database )ile %ontains user pass ord database )ile %ontains group database )ile %ontains group pass ord database
44
UmasB
umas! is a value 'i%' is subtra%ted )rom de)ault to determine ne )ile5 dire%tory permissions >e)ault permission )or )iles is 666 >e)ault permission )or dire%tories is 777 /efault "ermission H UmasB M :ffecti9e "ermission M Non1Crivileged Users umasB is 00/ Files ill 'ave permissions o) 66 >ire%tories ill 'ave permission o) 77B M root2s umas! is 0// M ?xample G1 M 666 U 00/ O &&4 M 666 U /-- O 422 M 777 U /// O ### M 777 U 0/7 O )#L
4-
Permissions
r w x r x r x Owner has read Owner has write Owner has execute Group has read Group does not have write Group has execute Others have read Others do not have write Others have execute
4B
4770 -BB1
dirname pass d
=eatures of :xt2
0'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# 0'is means t'at i) a dis! develops a problem8 t'e superuser %an still a%%ess t'at dis! and re%ti)y it
46
ot'er %ommon )ilesystem are :+1>*+ (F304/8 N0F+8 I+*9660) 0'e ext4 )ile system is essentially an en'an%ed version o) t'e ext/ )ile system# 3dvantages areG
19aila3ility
3)ter an po er )ailure or system %ras' (also %alled an unclean system shutdown)8 ea%' mounted ext/ )ile system on t'e ma%'ine must be %'e%!ed )or %onsisten%y by t'e e2fscB program# 0'is is a time1%onsuming pro%ess t'at %an delay system boot time signi)i%antly8 espe%ially it' large volumes# 0'e $ournaling provided by t'e ext4 )ile system means t'at t'is sort o) )ile system %'e%! is no longer ne%essary a)ter an un%lean system s'utdo n# 0'e only time a %onsisten%y %'e%! o%%urs using ext4 is in %ertain rare 'ard are )ailure %ases8 su%' as 'ard drive )ailures#
/ata Integrity
0'e ext4 )ile system prevents loss o) data integrity in t'e event t'at an un%lean system s'utdo n o%%urs# 0'e ext4 )ile system allo s you to %'oose t'e type and level o) prote%tion t'at your data re%eives#
LinBs
3 lin! is a )ile t'at points to anot'er )ile# ,lnL %reates a ,lin!L )rom t'e original )ile to a ne ,)ileL in your dire%tory# :ost programs ill a%%ess t'e lin! as i) it as t'e )ile# 0'is is similar to a ,s'ort%utL in <indo s# 0'is allo s )or aliasing ( 'en t o or more names %an exist )or t'e same ob$e%t) ?asy ay to point to a really long absolute pat'name or )ilename
Using LinBs
$wo ty!es of linBs can 3e created M +ymboli% ( +o)t ) M ;ard ln +s main soft ( 0'is ill %reate an so)t lin! o) )ile ,mainL ) ln main hard ( 0'is ill %reate an 'ard lin! o) )ile ,mainL )
47
mount 'media'flo!!y mount 'media'cdrom mount 'media'/e9ice I/ "ommands to unmount media umount 'media'flo!!y umount 'media'cdrom umount 'media'/e9ice I/
O O
:ounts )loppy drive to your %omputer O :ounts %drom drive to your %omputer :ounts usb dis! to your %omputer
O O O
Unmounts )loppy drive to your %omputer Unmounts %drom drive to your %omputer Unmounts usb dis! to your %omputer
1rchi9e =iles
3r%'iving pla%es many )iles into one target )ile ?asier to ba%! up8 store8 and trans)er tar U +tandard Linux ar%'iving %ommand
=ile Aom!ression
=esults in smaller )ile si(e 0ext )iles %an be %ompressed over 7BS tar ar%'ives are o)ten %ompressed
Aom!ression Utilities
g@i!, gun@i! M +tandard Linux %ompression utility M Up to 7BS %ompression )or text )iles 3@i!2, 3un@i!2 M Ne er Linux %ompression utility M &enerally a%'ieves better %ompression t'an g(ip
Using Aom!ression
g@i! somefile ( 0o %reate %ompressed )ile ) gun@i! somefile ( 0o un%ompress a %ompressed )ile ) 3@i!2 somefile ( 0o %reate %ompressed )ile ) 3un@i!2 somefile ( 0o un%ompress a %ompressed )ile )
4@
*oteG 1 <e %an use @ for g@i! and > for 3@i!2 type o) %ompression it' tar
(ut!ut (!tion8+
+9 +h
OUsed )or print pa%!age nameP OUsed )or print 'as' mar!sP
'i%' is invo!ed it' r!m +N or r!mNuery. euery option )all into one o) t o %ategoriesG t'ose t'at spe%i)y 'i%'
pa%!ages to Duery8 and t'ose t'at spe%i)y 'at in)ormation to retrieve# 0'e )irst must be spe%i)ied. t'e se%ond de)aults to t'e pa%!age name# %yntax8 + r!m +Na Yless r!m +Nf filename Os'o o ning pa%!ageP r!m +Ni !acBageWname Ogeneral in)ormationP r!m +Nl !acBageWname Olists )iles in pa%!ageP
-0