0% found this document useful (0 votes)
96 views

Unix Linux Introduction

This document is best viewed with a recent PDF reader or with OpenOffice.org itself. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one. Command memento sheet it is a useful companion to this presentation. Examples for the most useful commands are given in just one sheet.

Uploaded by

Udea En Cristo
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
96 views

Unix Linux Introduction

This document is best viewed with a recent PDF reader or with OpenOffice.org itself. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one. Command memento sheet it is a useful companion to this presentation. Examples for the most useful commands are given in just one sheet.

Uploaded by

Udea En Cristo
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 157

TheUnixandGNU/Linuxcommandline

TheUnixand GNU/Linux commandline


MichaelOpdenacker FreeElectrons

1
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Rightstocopy
Copyright20042008,FreeElectrons [email protected] Documentsources,updatesandtranslations: http://freeelectrons.com/docs/commandline Corrections,suggestions,contributionsand translationsarewelcome!
AttributionShareAlike3.0 Youarefree tocopy,distribute,display,andperformthework tomakederivativeworks tomakecommercialuseofthework Underthefollowingconditions Attribution.Youmustgivetheoriginalauthorcredit. ShareAlike.Ifyoualter,transform,orbuilduponthiswork,you maydistributetheresultingworkonlyunderalicenseidenticalto thisone. Foranyreuseordistribution,youmustmakecleartoothersthelicense termsofthiswork. Anyoftheseconditionscanbewaivedifyougetpermissionfromthe copyrightholder. Yourfairuseandotherrightsareinnowayaffectedbytheabove. Licensetext:http://creativecommons.org/licenses/bysa/3.0/legalcode

Latestupdate:Jan3,2009

2
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Bestviewedwith...
ThisdocumentisbestviewedwitharecentPDFreader orwithOpenOffice.orgitself! Takeadvantageofinternalorexternalhyperlinks. So,donthesitatetoclickonthem!Seenextpage. Findpagesquicklythankstoautomaticsearch Usethumbnailstonavigateinthedocumentinaquickway IfyourereadingapaperorHTMLcopy,youshouldgetyour copyinPDForOpenOffice.orgformaton http://freeelectrons.com/docs/commandline!

3
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Commandmementosheet
Itisausefulcompaniontothis presentation. Examplesforthemostuseful commandsaregiveninjustone sheet. Suggestionsforuse Stickthissheetonyourwall,useit asdesktopwallpaper,makeita mousemat,printitonclothing, sliceitintobookmarks... Caution Storeawayfrommice!
Getiton http://freeelectrons.com/docs/commandline
4
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

TrainingContents(1)
Shells,filesystemandfilehandling Everythingisafile GNU/Linuxfilesystemstructure Commandlineinterpreters Handlingfilesanddirectories Displaying,scanningandsortingfiles Symbolicandhardlink Fileaccessrights

5
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Trainingcontents(2)
StandardI/O,redirections,pipes Standardinputandoutput,redirectingtofiles Pipes:redirectingstandardoutputtoothercommands Standarderror

6
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

TrainingContents(3)
Taskcontrol Fullcontrolontasks Executinginbackground,suspending,resumingandaborting Listofactivetasks Killingprocesses Environmentvariables PATHenvironmentvariables Shellaliases,.bashrcfile

7
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Trainingcontents(4)
Miscellaneous

Texteditors Compressingandarchiving Printingfiles Comparingfilesanddirectories Lookingforfiles Gettinginformationaboutusers

8
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Trainingcontents(5)
Systemadministrationbasics Settingupnetworking Filesystems:creatingandmounting Goingfurther Gettinghelp,accessingmanualpages SearchingtheInternetforresources

9
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

GNU/LinuxandFreeSoftware
ThispresentationincludedanintroductiontoFreeSoftware andOpenSource:operatingsystems,applications,key projectsandrulesforsuccess. Itisnowavailableasaseparatepresentation: http://freeelectrons.com/articles/freesw

10
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

TheUnixandGNU/Linuxcommandline

Unixfilesystem

11
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Everythingisafile
AlmosteverythinginUnixisafile! Regularfiles Directories Directoriesarejustfiles listingasetoffiles Symboliclinks Filesreferringtothename ofanotherfile Devicesandperipherals Readandwritefromdevices aswithregularfiles Pipes Usedtocascadeprograms cat*.log|greperror Sockets Interprocesscommunication

12
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Filenames
FilenamefeaturessincethebeginningofUnix Casesensitive Noobviouslengthlimit Cancontainanycharacter(includingwhitespace,except/). Filetypesstoredinthefile(magicnumbers). Filenameextensionsnotneededandnotinterpreted.Just usedforuserconvenience. Filenameexamples: README .bashrc index.htm index.html WindowsBuglist index.html.old

13
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Filepaths
Apathisasequenceofnesteddirectorieswithafileor directoryattheend,separatedbythe/character Relativepath:documents/fun/microsoft_jokes.html Relativetothecurrentdirectory Absolutepath: /home/bill/bugs/crash9402031614568 /:rootdirectory. Startofabsolutepathsforallfilesonthesystem(evenfor filesonremovabledevicesornetworkshared).

14
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

GNU/Linuxfilesystemstructure(1)
Notimposedbythesystem.Canvaryfromonesystemtothe other,evenbetweentwoGNU/Linuxinstallations! / /bin/ /boot/ /dev/ /etc/ /home/ /lib/ Rootdirectory Basic,essentialsystemcommands Kernelimages,initrdandconfigurationfiles Filesrepresentingdevices /dev/hda:firstIDEharddisk Systemconfigurationfiles Userdirectories Basicsystemsharedlibraries

15
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

GNU/Linuxfilesystemstructure(2)
/lost+found /media /mnt/ filesystems /opt/ /proc/ /root/ /sbin/ /sys/ Corruptfilesthesystemtriedtorecover Mountpointsforremovablemedia: /media/usbdisk,/media/cdrom Mountpointsfortemporarilymounted Specifictoolsinstalledbythesysadmin /usr/local/oftenusedinstead Accesstosysteminformation /proc/cpuinfo,/proc/version... rootuserhomedirectory Administratoronlycommands Systemanddevicecontrols (cpufrequency,devicepower,etc.)
16
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

GNU/Linuxfilesystemstructure(3)
/tmp/ /usr/ /usr/local/ /var/ Temporaryfiles Regularusertools(notessentialtothesystem) /usr/bin/,/usr/lib/,/usr/sbin... Specificsoftwareinstalledbythesysadmin (oftenpreferredto/opt/) Datausedbythesystemorsystemservers /var/log/,/var/spool/mail(incoming mail),/var/spool/lpd(printjobs)...

TheUnixfilesystemstructureisdefined bytheFilesystemHierarchyStandard(FHS): http://www.pathname.com/fhs/

17
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

TheUnixandGNU/Linuxcommandline

Shellsandfilehandling

18
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Commandlineinterpreters
Shells:toolstoexecuteusercommands Calledshellsbecausetheyhidethedetailsonthe underlyingoperatingsystemundertheshell'ssurface. Commandsareinputinatextterminal,eitherawindow inagraphicalenvironmentoratextonlyconsole. Resultsarealsodisplayedontheterminal.Nographics areneededatall. Shellscanbescripted:providealltheresourcesto writecomplexprograms(variable,conditionals, iterations...)

19
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Wellknownshells
Mostfamousandpopularshells sh:TheBourneshell(obsolete) Traditional,basicshellfoundonUnixsystems,bySteveBourne. csh:TheCshell(obsolete) OncepopularshellwithaClikesyntax tcsh:TheTCshell(stillverypopular) ACshellcompatibleimplementationwithevolvedfeatures (commandcompletion,historyeditingandmore...) bash:TheBourneAgainshell(mostpopular) Animprovedimplementationofshwithlotsofaddedfeatures too.

20
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

fish:agreatnewshell
TheFriendlyInteractiveSHell http://www.fishshell.org/ Standardfeatures:history,commandandfilecompletion... Brandnewfeatures:commandoptioncompletion,command completionwithshortdescription,syntaxhighlighting.. Easiertoanyopenfiles:openbuiltincommand. Muchsimplerandconsistentsyntax(notPOSIXcompliant) Makesiteasiertocreateshellscripts. Commandlinebeginnerscanlearnmuchfaster! Evenexperiencedusersshouldfindthisshellveryconvenient.

21
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

lscommand
Liststhefilesinthecurrentdirectory,inalphanumericorder, exceptfilesstartingwiththe.character. lsa(all) Listsallthefiles(including.* files) lsl(long) Longlisting(type,date,size, owner,permissions) lst(time) Liststhemostrecentfilesfirst lsS(size) Liststhebiggestfilesfirst lsr(reverse) Reversesthesortorder lsltr(optionscanbe combined) Longlisting,mostrecentfiles attheend

22
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Filenamepatternsubstitutions
Betterintroducedbyexamples! ls*txt Theshellfirstreplaces*txtbyallthefileanddirectory namesendingbytxt(including.txt),exceptthose startingwith.,andthenexecutesthelscommandline. lsd.* Listsallthefilesanddirectoriesstartingwith. dtellslsnottodisplaythecontentsofdirectories. cat?.log Displaysallthefileswhichnamesstartby1characterand endby.log

23
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Specialdirectories(1)
./ Thecurrentdirectory.Usefulforcommandstakingadirectory argument.Alsosometimesusefultoruncommandsinthe currentdirectory(seelater). So./readme.txtandreadme.txtareequivalent. ../ Theparent(enclosing)directory.Alwaysbelongstothe. directory(seelsa).Onlyreferencetotheparentdirectory. Typicalusage: cd..

24
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Specialdirectories(2)
~/ Notaspecialdirectoryindeed.Shellsjustsubstituteit bythehomedirectoryofthecurrentuser. Cannotbeusedinmostprograms,asitisnotareal directory. ~sydney/ Similarly,substitutedbyshellsbythehomedirectoryof thesydneyuser.

25
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Thecdandpwdcommands
cd<dir> Changesthecurrentdirectoryto<dir>. cd Getsbacktothepreviouscurrentdirectory. pwd Displaysthecurrentdirectory("workingdirectory").

26
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Thecpcommand
cp<source_file><target_file> Copiesthesourcefiletothetarget. cpfile1file2file3...dir Copiesthefilestothetargetdirectory(lastargument). cpi(interactive) Asksforuserconfirmationifthetargetfilealreadyexists cpr<source_dir><target_dir>(recursive) Copiesthewholedirectory.

27
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Smartdirectorycopywithrsync
rsync(remotesync)hasbeendesignedtokeepinsync directorieson2machineswithalowbandwidthconnection.
Onlycopiesfilesthathavechanged.Fileswiththesamesizeare comparedbychecksums. Onlytransferstheblocksthatdifferwithinafile! Cancompressthetransferredblocks Preservessymboliclinksandfilepermissions:alsoveryusefulfor copiesonthesamemachine. Canworkthroughssh(secureremoteshell).Veryusefultoupdate thecontentsofawebsite,forexample.

28
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

rsyncexamples(1)
rsynca/home/arvin/sd6_agents//home/sydney/misc/

a:archivemode.EquivalenttorlptgoD...easywaytotellyou wantrecursionandwanttopreservealmosteverything.
rsyncPavdelete/home/steve/ideas//home/bill/my_ideas/

P:partial(keeppartiallytransferredfiles)andprogress (showprogressduringtransfer) delete:deletefilesinthetargetwhichdon'texistinthesource. Caution:directorynamesshouldendwith/.Otherwise,yougeta my_ideas/ideas/directoryatthedestination.

29
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

rsyncexamples(2)
Copyingtoaremotemachine rsyncPav/home/bill/legal/arguments/\ [email protected]:/home/legal/arguments/ Userbillwillbepromptedforapassword. Copyingfromaremotemachinethroughssh rsyncPavessh [email protected]:/prod/beer/\ fridge/homer/beer/ Userhomerwillbepromptedforhissshkeypassword.

30
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

mvandrmcommands
mv<old_name><new_name> (move) Renamesthegivenfileordirectory. mvi(interactive) Ifthenewfilealreadyexits,asksforuserconfirm rmfile1file2file3... (remove) Removesthegivenfiles. rmi(interactive) Alwaysaskforuserconfirm. rmrdir1dir2dir3(recursive) Removesthegivendirectorieswithalltheircontents.

31
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Creatingandremovingdirectories
mkdirdir1dir2dir3...(makedir) Createsdirectorieswiththegivennames. rmdirdir1dir2dir3...(removedir) Removesthegivendirectories Safe:onlyworkswhendirectoriesandempty. Alternative:rmr(doesn'tneedemptydirectories).

32
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Displayingfilecontents
Severalwaysofdisplayingthecontentsoffiles. catfile1file2file3...(concatenate) Concatenatesandoutputsthecontentsofthegivenfiles. morefile1file2file3... Aftereachpage,askstheusertohitakeytocontinue. Canalsojumptothefirstoccurrenceofakeyword (/command). lessfile1file2file3... Doesmorethanmorewithless. Doesn'treadthewholefilebeforestarting. Supportsbackwardmovementinthefile(?command).

33
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Theheadandtailcommands
head[<n>]<file> Displaysthefirst<n>lines(or10bydefault)ofthegivenfile. Doesn'thavetoopenthewholefiletodothis! tail[<n>]<file> Displaysthelast<n>lines(or10bydefault)ofthegivenfile. NoneedtoloadthewholefileinRAM!Veryusefulforhugefiles. tailf<file>(follow) Displaysthelast10linesofthegivenfileandcontinuestodisplaynew lineswhentheyareappendedtothefile. Veryusefultofollowthechangesinalogfile,forexample. Examples headwindows_bugs.txt tailfoutlook_vulnerabilities.txt

34
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Thegrepcommand
grep<pattern><files> Scansthegivenfilesanddisplaysthelineswhichmatchthegiven pattern. greperror*.log Displaysallthelinescontainingerrorinthe*.logfiles grepierror*.log Same,butcaseinsensitive greprierror. Same,butrecursivelyinallthefilesin.anditssubdirectories grepvinfo*.log Outputsallthelinesinthefilesexceptthosecontaininginfo.

35
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Thesortcommand
sort<file> Sortsthelinesinthegivenfileincharacterorder andoutputsthem. sortr<file> Same,butinreverseorder. sortru<file> u:unique.Same,butjustoutputsidenticallines once. Morepossibilitiesdescribedlater!

36
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Symboliclinks
Asymboliclinkisaspecialfilewhichisjustareferencetothe nameofanotherone(fileordirectory): Usefultoreducediskusageandcomplexitywhen2fileshave thesamecontent. Example:
anakin_skywalker_biography>darth_vador_biography

Howtoidentifysymboliclinks: lsldisplays>andthelinkedfilename. GNUlsdisplayslinkswithadifferentcolor.

37
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Creatingsymboliclinks
Tocreateasymboliclink(sameorderasincp): lnsfile_namelink_name Tocreatealinkwithtoafileinanotherdirectory,with thesamename: lns../README.txt Tocreatemultiplelinksatonceinagivendirectory: lnsfile1file2file3...dir Toremovealink: rmlink_name Ofcourse,thisdoesn'tremovethelinkedfile!

38
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Hardlinks
Thedefaultbehaviorforlnistocreatehardlinks Ahardlinktoafileisaregularfilewithexactlythe samephysicalcontents Whiletheystillsavespace,hardlinkscan'tbe distinguishedfromtheoriginalfiles. Ifyouremovetheoriginalfile,thereisnoimpactonthe hardlinkcontents. Thecontentsareremovedwhentherearenomorefiles (hardlinks)tothem.

39
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Filesnamesandinodes
Makeshardandsymbolic(soft)linkseasiertounderstand!
Users Filenameinterface

Softlink

rm

File Inode

Hardlink
rm

Inode interface Filesystem

40
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Fileaccessrights
Uselsltocheckfileaccessrights
3typesofaccessrights Readaccess(r) Writeaccess(w) Executerights(x) 3typesofaccesslevels User(u):fortheownerofthe file Group(g):eachfilealsohas agroupattribute, correspondingtoagivenlist ofusers Others(o):forallotherusers

41
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Accessrightconstraints
xwithoutrislegalbutisuseless Youhavetobeabletoreadafiletoexecuteit. Bothrandxpermissionsneededfordirectories: xtoenter,rtolistitscontents. Youcan'trename,remove,copyfilesinadirectoryifyou don'thavewaccesstothisdirectory. Ifyouhavewaccesstoadirectory,youCANremoveafile evenifyoudon'thavewriteaccesstothisfile(remember thatadirectoryisjustafiledescribingalistoffiles).This evenletsyoumodify(remove+recreate)afileevenwithout waccesstoit.

42
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Accessrightsexamples
rwrr Readableandwritableforfileowner,onlyreadablefor others rwr Readableandwritableforfileowner,onlyreadableforusers belongingtothefilegroup. drwx Directoryonlyaccessiblebyitsowner rx Fileexecutablebyothersbutneitherbyyourfriendsnorby yourself.Niceprotectionsforatrap...

43
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

chmod:changingpermissions
chmod<permissions><files> 2formatsforpermissions: Octalformat(abc): a,b,c=r*4+w*2+x(r,w,x:booleans) Example:chmod644<file> (rwforu,rforgando) Orsymbolicformat.Easytounderstandbyexamples: chmodgo+r:addreadpermissionstogroupand others. chmoduw:removewritepermissionsfromuser. chmodax:(a:all)removeexecutepermissionfromall.
44
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Morechmod(1)
chmodRa+rXlinux/ Makeslinuxandeverythinginitavailableto everyone! R:applychangesrecursively X:x,butonlyfordirectoriesandfilesalready executable Veryusefultoopenrecursiveaccesstodirectories, withoutaddingexecutionrightstoallfiles.

45
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Morechmod(2)
chmoda+t/tmp t:(sticky).Specialpermissionfordirectories,allowing onlythedirectoryandfileownertodeleteafileina directory. Usefulfordirectorieswithwriteaccesstoanyone, like/tmp. Displayedbylslwithatcharacter.

46
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

TheUnixandGNU/Linuxcommandline

StandardI/O,redirections,pipes

47
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Standardoutput
Moreaboutcommandoutput Allthecommandsoutputtingtextonyourterminaldoitby writingtotheirstandardoutput. Standardoutputcanbewritten(redirected)toafileusing the>symbol Standardoutputcanbeappendedtoanexistingfileusing the>>symbol

48
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Standardoutputredirectionexamples
ls~saddam/*>~gwb/weapons_mass_destruction.txt catobiwan_kenobi.txt>starwars_biographies.txt cathan_solo.txt>>starwars_biographies.txt echoREADME:Nosuchfileordirectory>README Usefulwayofcreatingafilewithoutatexteditor. NiceUnixjoketoointhiscase.

49
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Standardinput
Moreaboutcommandinput Lotsofcommands,whennotgiveninputarguments,can taketheirinputfromstandardinput. sort windows linux [Ctrl][D] linux windows sorttakesitsinputfrom thestandardinput:inthiscase, whatyoutypeintheterminal (endedby[Ctrl][D])

sort<participants.txt Thestandardinputofsortistakenfromthegivenfile.

50
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Pipes
Unixpipesareveryusefultoredirectthestandardoutputofa commandtothestandardinputofanotherone. Examples
cat*.log|grepierror|sort greprierror.|grepvignored|sortu\ >serious_errors.log cat/home/*/homework.txt|grepmark|more

ThisoneofthemostpowerfulfeaturesinUnixshells!

51
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Theteecommand
tee[a]file Theteecommandcanbeusedtosendstandard outputtothescreenandtoafilesimultaneously. make|teebuild.log Runsthemakecommandandstoresitsoutputto build.log. makeinstall|teeabuild.log Runsthemakeinstallcommandandappends itsoutputtobuild.log.

52
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Standarderror
Errormessagesareusuallyoutput(iftheprogramiswell written)tostandarderrorinsteadofstandardoutput. Standarderrorcanberedirectedthrough2>or2>> Example: catf1f2nofile>newfile2>errfile Note:1isthedescriptorforstandardoutput,so1>isequivalentto >. Canredirectbothstandardoutputandstandarderrortothe samefileusing&>: catf1f2nofile&>wholefile

53
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Theyescommand
Usefultofillstandardinputwithalwaysthesamestring. yes<string>|<command> Keepsfillingthestandardinputof<command>with <string>(ybydefault). Examples yes|rmrdir/ bank>yesno|credit_applicant yes""|makeoldconfig (equivalenttohitting[Enter]toacceptalldefaultsettings)

54
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Specialdevices(1)
Devicefileswithaspecialbehaviororcontents /dev/null Thedatasink!Discardsalldatawrittentothisfile. Usefultogetridofunwantedoutput,typicallylog information: mplayerblack_adder_4th.avi&>/dev/null /dev/zero Readsfromthisfilealwaysreturn\0characters Usefultocreateafilefilledwithzeros: ddif=/dev/zeroof=disk.imgbs=1kcount=2048 Seemannullormanzerofordetails

55
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Specialdevices(2)
/dev/random Returnsrandombyteswhenread.Mainlyusedby cryptographicprograms.Usesinterruptsfromsomedevice driversassourcesoftruerandomness(entropy). Readscanbeblockeduntilenoughentropyisgathered. /dev/urandom Forprogramsforwhichpseudorandomnumbersarefine. Alwaysgeneratesrandombytes,evenifnotenoughentropy isavailable(inwhichcaseitispossible,thoughstilldifficult, topredictfuturebytesequencesfrompastones). Seemanrandomfordetails.

56
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Specialdevices(3)
/dev/full Mimicsafulldevice. Usefultocheckthatyourapplicationproperlyhandles thiskindofsituation. Seemanfullfordetails.

57
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

TheUnixandGNU/Linuxcommandline

Taskcontrol

58
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Fullcontrolontasks
Sincethebeginning,Unixsupportstruepreemptive multitasking. Abilitytorunmanytasksinparallel,andabortthemevenif theycorrupttheirownstateanddata. Abilitytochoosewhichprogramsyourun. Abilitytochoosewhichinputyourprogramstakes,and wheretheiroutputgoes.

59
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Processes
EverythinginUnixisafile EverythinginUnixthatisnotafileisaprocess Processes Instancesofarunningprograms Severalinstancesofthesameprogramcanrunatthesametime Dataassociatedtoprocesses: Openfiles,allocatedmemory,stack,processid,parent,priority, state...

60
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Runningjobsinbackground
Sameusagethroughoutalltheshells Useful
Forcommandlinejobswhichoutputcanbeexaminedlater, especiallyfortimeconsumingones. Tostartgraphicalapplicationsfromthecommandlineand thencontinuewiththemouse.

Startingatask:add&attheendofyourline: find_prince_charmingcutecleverrich&

61
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Backgroundjobcontrol
jobs Returnsthelistofbackgroundjobsfromthesameshell
[1]Running~/bin/find_meaning_of_lifewithoutgod& [2]+Runningmakemistakes&

fg fg%<n> Putsthelast/nthbackgroundjobinforegroundmode Movingthecurrenttaskinbackgroundmode: [Ctrl]Z bg kill%<n> Abortsthenthjob.

62
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Jobcontrolexample
>jobs [1]Running~/bin/find_meaning_of_lifewithoutgod& [2]+Runningmakemistakes& >fg makemistakes >[Ctrl]Z [2]+Stoppedmakemistakes >bg [2]+makemistakes& >kill%1 [1]+Terminated~/bin/find_meaning_of_lifewithoutgod

63
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Listingallprocesses
...whatevershell,scriptorprocesstheyarestartedfrom psux Listsalltheprocessesbelongingtothecurrentuser psaux(Note:psedfonSystemVsystems) Listsalltheprocessesrunningonthesystem
psaux|grepbart|grepbash USERPID%CPU%MEMVSZRSSTTYSTATSTARTTIMECOMMAND bart30390.00.259161380pts/2S14:350:00/bin/bash bart31340.00.253881380pts/3S14:360:00/bin/bash bart31900.00.263681360pts/4S14:370:00/bin/bash bart34160.00.000pts/2RW15:070:00[bash] PID: VSZ: RSS: TTY: STAT: Processid Virtualprocesssize(code+data+stack) Processresidentsize:numberofKBcurrentlyinRAM Terminal Status:R(Runnable),S(Sleep),W(paging),Z(Zombie)...

64
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Liveprocessactivity
topDisplaysmostimportantprocesses,sortedbycpu percentage
top15:44:33up1:11,5users,loadaverage:0.98,0.61,0.59 Tasks:81total,5running,76sleeping,0stopped,0zombie Cpu(s):92.7%us,5.3%sy,0.0%ni,0.0%id,1.7%wa,0.3%hi,0.0%si Mem:515344ktotal,512384kused,2960kfree,20464kbuffers Swap:1044184ktotal,0kused,1044184kfree,277660kcached PIDUSERPRNIVIRTRESSHRS%CPU%MEMTIME+COMMAND 3809jdoe250625639321312R93.80.80:21.49bunzip2 2769root160157m80m90mR2.716.05:21.01X 3006jdoe1503092815m27mS0.33.00:22.40kdeinit 3008jdoe16056248924468S0.30.20:06.59autorun 3034jdoe1502676412m24mS0.32.50:12.68kscd 3810jdoe16028929161620R0.30.20:00.06top

Youcanchangethesortingorderbytyping M:Memoryusage,P:%CPU,T:Time. Youcankillataskbytypingkandtheprocessid.


65
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Killingprocesses(1)
kill<pids> Sendsanabortsignaltothegivenprocesses.Lets processessavedataandexitbythemselves.Shouldbeused first.Example: kill3039313431903416 kill9<pids> Sendsanimmediateterminationsignal.Thesystemitself terminatestheprocesses.Usefulwhenaprocessisreally stuck(doesn'tanswertokill1). kill91 Killsalltheprocessesofthecurrentuser.1:meansall processes.
66
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Killingprocesses(2)
killall[<signal>]<command> Killsallthejobsrunning<command>.Example: killallbash xkill Letsyoukillagraphicalapplicationbyclickingonit! Veryquick!Convenientwhenyoudon'tknowtheapplication commandname.

67
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Recoveringfromstuckgraphics
Ifyourgraphicalsessionisstuckandyoucannolongertypeinyour terminals,don'treboot! Itisverylikelythatyoursystemisstillfine.Trytoaccessatext consolebypressingthe[Ctrl][Alt][F1]keys (or[F2],[F3]formoretextconsoles) Inthetextconsole,youcantrytokilltheguiltyapplication. Oncethisisdone,youcangobacktothegraphicsessionby pressing[Ctrl][Alt][F5]or[Ctrl][Alt][F7](dependingon yourdistribution) Ifyoucan'tidentifythestuckprogram,youcanalsokillallyourprocesses: kill91 Youarethenbroughtbacktotheloginscreen.

68
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Sequentialcommands
Cantypethenextcommandinyourterminalevenwhen thecurrentoneisnotover. Canseparatecommandswiththe;symbol: echoIlovethee;sleep10;echonot Conditionals:use||(or)or&&(and): moreGod||echoSorry,Goddoesn'texist Runsechoonlyifthefirstcommandfails ls~sd6&&cat~sd6/*>~sydney/recipes.txt Onlycatsthedirectorycontentsifthelscommandsucceeds (meansreadaccess).

69
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Quoting(1)
Double(")quotescanbeusedtopreventtheshellfrom interpretingspacesasargumentseparators,aswellasto preventfilenamepatternexpansion. >echo"HelloWorld" HelloWorld >echo"Youareloggedas$USER" Youareloggedasbgates >echo*.log find_prince_charming.logcosmetic_buys.log >echo"*.log" *.log

70
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Quoting(2)
Singlequotesbringasimilarfunctionality,butwhatisbetween quotesisneversubstituted >echo'Youareloggedas$USER' Youareloggedas$USER Backquotes(`)canbeusedtocallacommandwithinanother >cd/lib/modules/`unamer`;pwd /lib/modules/2.6.91.6_FC2 Backquotescanbeusedwithindoublequotes >echo"YouareusingLinux`unamer`" YouareusingLinux2.6.91.6_FC2

71
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Measuringelapsedtime
timefind_expensive_housingnear <...commandoutput...> real0m2.304s(actualelapsedtime) user0m0.449s(CPUtimerunningprogramcode) sys0m0.106s(CPUtimerunningsystemcalls) real=user+sys+waiting waiting=I/Owaitingtime+idletime(runningothertasks)

72
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Environmentvariables
Shellslettheuserdefinevariables. Theycanbereusedinshellcommands. Convention:lowercasenames Youcanalsodefineenvironmentvariables: variablesthatarealsovisiblewithinscriptsor executablescalledfromtheshell. Convention:uppercasenames. env Listsalldefinedenvironmentvariablesandtheir value.

73
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Shellvariablesexamples
Shellvariables(bash) projdir=/home/marshall/coolstuff lsla$projdir;cd$projdir Environmentvariables(bash) cd$HOME exportDEBUG=1 ./find_extraterrestrial_life (displaysdebuginformationifDEBUGisset)

74
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Mainstandardenvironmentvariables
Usedbylotsofapplications!
LD_LIBRARY_PATH MANPATH

Manualpagesearchpath
PATH

Sharedlibrarysearchpath
DISPLAY

Commandsearchpath
PRINTER

ScreenidtodisplayX (graphical)applicationson.
EDITOR

Defaultprintername
SHELL

Defaulteditor(vi,emacs...)
HOME

Currentshellname
TERM

Currentuserhome directory
HOSTNAME

Currentterminaltype
USER

Nameofthelocalmachine

Currentusername

75
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

PATHenvironmentvariables
PATH Specifiestheshellsearchorderforcommands / home/acox/bin:/usr/local/bin:/usr/kerberos/bin: /usr/bin:/bin:/usr/X11R6/bin:/bin:/usr/bin LD_LIBRARY_PATH Specifiesthesharedlibrary(binarycodelibrariessharedby applications,liketheClibrary)searchorderforld /usr/local/lib:/usr/lib:/lib:/usr/X11R6/lib MANPATH Specifiesthesearchorderformanualpages /usr/local/man:/usr/share/man
76
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

PATHusagewarning
Itisstronglyrecommendednottohavethe.directoryinyour PATHenvironmentvariable,inparticularnotatthebeginning: Acrackercouldplaceamaliciouslsfileinyourdirectories.It wouldgetexecutedwhenyourunlsinthisdirectoryandcould donaughtythingstoyourdata. Ifyouhaveanexecutablefilecalledtestinadirectory,thiswill overridethedefaulttestprogramandsomescriptswillstop workingproperly. Eachtimeyoucdtoanewdirectory,theshellwillwastetime updatingitslistofavailablecommands. Callyourlocalcommandsasfollows:./test

77
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Alias
Shellsletyoudefinecommandaliases:shortcutsforcommandsyou useveryfrequently. Examples
aliasls='lsla' Usefultoalwaysruncommandswithdefaultarguments. aliasrm='rmi' Usefultomakermalwaysaskforconfirmation. aliasfrd='find_rambaldi_deviceasaprisky' Usefultoreplaceverylongandfrequentcommands. aliascia='./home/sydney/env/cia.sh' Usefultosetanenvironmentinaquickway (.isashellcommandtoexecutethecontentofashellscript).

78
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Thewhichcommand
Beforeyourunacommand,whichtellsyouwhereitisfound bash>whichls aliasls='lscolor=tty' /bin/ls tcsh>whichls ls:aliasedtolscolor=tty bash>whichalias /usr/bin/which:noaliasin (/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin) tcsh>whichalias alias:shellbuiltincommand.

79
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

~/.bashrcfile
~/.bashrc
Shellscriptreadeachtimeabashshellisstarted Youcanusethisfiletodefine Yourdefaultenvironmentvariables(PATH,EDITOR...). Youraliases. Yourprompt(seethebashmanualfordetails). Agreetingmessage.

80
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Commandediting
Youcanusetheleftandrightarrowkeystomovethecursor inthecurrentcommand. Youcanuse[Ctrl][a]togotothebeginningoftheline, and[Ctrl][e]togototheend. Youcanusetheupanddownarrowstoselectearlier commands.

81
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Commandhistory(1)
history Displaysthelatestcommandsthatyouranandtheir number.Youcancopyandpastecommandstrings. Youcanrecallthelatestcommand: !! Youcanrecallacommandbyitsnumber !1003 Youcanrecallthelatestcommandmatchingastarting string: !cat

82
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Commandhistory(2)
Youcanmakesubstitutionsonthelatestcommand: ^more^less Youcanrunanothercommandwiththesamearguments: more!*

83
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

TheUnixandGNU/Linuxcommandline

Miscellaneous
Texteditors

84
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Texteditors
Graphicaltexteditors Fineformostneeds nedit Emacs,Xemacs Textonlytexteditors Oftenneededforsysadminsandgreatforpowerusers vi nano

85
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Thenedittexteditor
http://www.nedit.org/ Besttexteditorfornonvioremacsexperts Featurehighlights:
Veryeasytextselectionandmoving Syntaxhighlightingformostlanguagesandformats.Canbe tailoredforyourownlogfiles,tohighlightparticularerrorsand warnings. Easytocustomizethroughmenus

Notinstalledbydefaultbyalldistributions

86
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

neditscreenshot

87
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Emacs/Xemacs
EmacsandXemacsarepretty similar(uptoyourpreference) Extremelypowerfultexteditor features Greatforpowerusers Lessergonomicthannedit Nonstandardshortcuts Muchmorethanatexteditor (games,email,shell,browser). Somepowercommandshavetobe learnt.

88
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

vi
TextmodetexteditoravailableinallUnixsystems.Created beforecomputerswithmiceappeared. Difficulttolearnforbeginnersusedtographicaltexteditors. Veryproductiveforpowerusers. Oftencan'tbereplacedtoeditfilesinsystemadministration orinEmbeddedSystems,whenyoujusthaveatext console.

89
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

vimviimproved
viimplementationnowfoundinmostGNU/ Linuxhostsystems Implementslotsoffeaturesavailableinmodern editors:syntaxhighlighting,commandhistory, help,unlimitedundoandmuchmuchmore. Coolfeatureexample:candirectlyopen compressedtextfiles. ComeswithaGTKgraphicalinterface(gvim) Unfortunately,notfreesoftware(becauseofa smallrestrictioninfreedomtomakechanges)

90
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

vibasiccommands
Thoughviisextremely powerful,itsmain30 commandsareeasytolearn andaresufficientfor99%of everyone'sneeds! Youcanalsotakethequick tutorialbyrunning vimtutor. Getourvimementosheetifyoudidn'tgetitwiththiscourse: http://freeelectrons.com/docs/commandline

91
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

GNUnano
http://www.nanoeditor.org/ Anothersmalltextonly,mousefreetexteditor. AnenhancedPicoclone(nonfreeeditorinPine) Friendlyandeasiertolearnforbeginnersthankstoon screencommandsummaries. Availableinbinarypackagesforseveralplatforms. Analternativetoviinembeddedsystems. However,notavailableasabusyboxbuiltin.

92
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

GNUnanoscreenshot

93
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

TheUnixandGNU/Linuxcommandline

Miscellaneous
Compressingandarchiving

94
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Measuringdiscusage
Caution:differentfromfilesize!

duh<file>(diskusage) h:returnssizeondiskofthegivenfile,inhuman readableformat:K(kilobytes),M(megabytes)orG (gigabytes),.Withouth,dureturnstherawnumberof diskblocksusedbythefile(hardtoread). NotethatthehoptiononlyexistsinGNUdu. dush<dir> s:returnsthesumofdiskusageofallthefilesinthe givendirectory.

95
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Measuringdiskspace
dfh<dir> Returnsdiskusageandfreespaceforthefilesystem containingthegivendirectory. Similarly,thehoptiononlyexistsinGNUdf. Example:
>dfh. FilesystemSizeUsedAvailUse%Mountedon /dev/hda59.2G7.1G1.8G81%/

dfh Returnsdiskspaceinformationforallfilesystems availableinthesystem.Whenerrorshappen,usefulto lookforfullfilesystems.


96
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Compressing
Veryusefulforshrinkinghugefilesandsavingspace g[un]zip<file> GNUzipcompressionutility.Creates.gzfiles. Ordinaryperformance(similartoZip). b[un]zip2<file> Morerecentandeffectivecompressionutility. Creates.bz2files.Usually2025%betterthangzip. Using7zip Muchbettercompressionratiothanbzip2(upto10to20%). Seethe7zippagefordetails.

97
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Archiving(1)
Usefultobackuporreleaseasetoffileswithin1file tar:originallytapearchive Creatinganarchive: tarcvf<archive><filesordirectories> c:create v:verbose.Usefultofollowarchivingprogress. f:file.Archivecreatedinfile(tapeusedotherwise). Example: tarcvf/backup/home.tar/home bzip2/backup/home.tar

98
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Archiving(2)
Viewingthecontentsofanarchiveorintegritycheck: tartvf<archive> t:test Extractingallthefilesfromanarchive: tarxvf<archive> Extractingjustafewfilesfromanarchive: tarxvf<archive><filesordirectories> Filesordirectoriesaregivenwithpathsrelativetothe archiverootdirectory.

99
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

ExtraoptionsinGNUtar
tar=gtar=GNUtaronGNU/Linux Cancompressanduncompressarchivesonthefly. Usefultoavoidcreatinghugeintermediatefiles Muchsimplertodothanwithtarandbzip2! joption:[un]compressesontheflywithbzip2 zoption:[un]compressesontheflywithgzip Examples(whichonewillyouremember?)
gtarjcvfbills_bugs.tar.bz2bills_bugs tarcvfbills_bugs|bzip2>bills_bugs.tar.bz2

100
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

7zip(1)
http://www.7zip.org/ Nowthebestsolutionforyourarchives! License:GNULGPL 7zipcompressesmuchbetterthanbzip2(upto10or20%) andofcoursezip(30to50%). BenchmarkcompressingKnoppix5.0.1:22%(vs.bzip2)! Caution:7zipcannotreplacetarforarchivingonUnix. Itdoesn'tkeepfileownerandgroupinformation, butofcoursekeepsfilepermissions. Useittocompresstararchives!

101
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

7zip(2)
7zipsupportsstrongAES256encryption. Noneedtoencryptinaseparatepass. AtlastasolutionavailableforUnixandWindows! Thetoolsupportsmostothercompressionformats: zip,cab,arj,gzip,bzip2,tar,cpio,rpmanddeb.

102
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Using7zip
Archivefilesareusuallycreatedwitha.7zextension Creatinganarchive:(a:add) 7za<archive><filesordirectories> Listfilesinarchive:(l:list) 7zl<archive> Extractingfroma7ziparchive:(e:extract) 7zx<archive> Backupadirectory(keepingownerandgroupinformation): tarcf<dir>|7zasidir.tar.7z Restorethisbackup: standardinput 7zxsodir.tar.7z|tarxf
standardoutput
103
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Checkingfileintegrity
Verylowcostsolutiontocheckfileintegrity md5sumFC3i386disk*.iso>MD5SUM ComputesaMD5(MessageDigestAlgorithm5)128bitchecksumofthe givenfiles.Usuallyredirectedtoafile. Exampleoutput: db8c7254beeb4f6b891d1ed3f689b412FC3i386disc1.iso 2c11674cf429fe570445afd9d5ff564eFC3i386disc2.iso f88f6ab5947ca41f3cf31db04487279bFC3i386disc3.iso 6331c00aa3e8c088cc365eeb7ef230eaFC3i386disc4.iso md5sumcMD5SUM CheckstheintegrityofthefilesinMD5SUMbycomparingtheiractualMD5 checksumwiththeiroriginalone.

104
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

TheUnixandGNU/Linuxcommandline

Miscellaneous
Printing

105
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Unixprinting
Multiuser,multijob,multiclient,multiprinter InUnix/Linux,printingcommandsdon'treallyprint.Theysend jobstoprintingqueues,possiblyonthelocalmachine,on networkprintingserversoronnetworkprinters. Printerindependentsystem: PrintserversonlyacceptjobsinPostScript ortext.Printerdriversontheservertake careoftheconversiontoeachprintersownformat. Robustsystem: Rebootasystem,itwillcontinuetoprintpendingjobs.

106
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Printingcommands
Usefulenvironmentvariable:PRINTER Setsthedefaultprinteronthesystem.Example: exportPRINTER=lp lpr[P<queue>]<files> Sendsthegivenfilestothespecifiedprintingqueue ThefilesmustbeintextorPostScriptformat.Otherwise, youonlyprintgarbage. a2ps[P<queue>]<files> AnytoPostScriptconvertsmanyformatstoPostScriptand sendtheoutputtothespecifiedqueue.Usefulfeatures: severalpages/sheet,pagenumbering,infoframe...

107
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Printjobcontrol
lpq[P<queue>] Listsalltheprintjobsinthegivenordefaultqueue.
lpisnotready RankOwnerJobFile(s)TotalSize 1stasloane84nsa_windows_backdoors.ps60416bytes 2ndamoore85gw_bush_iraq_mistakes.ps65024000bytes

cancel<job#>[<queue>] Removesthegivenjobnumberfromthedefaultqueue.

108
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

UsingPostScriptandPDFfiles
ViewingaPostScriptfile PostScriptviewersexist,buttheirqualityisprettypoor. BetterconverttoPDFwithps2pdf: ps2pdfdecss_algorithm.ps xpdfdecss_algorithm.pdf& PrintingaPDFfile Youdon'tneedtoopenaPDFreader! BetterconverttoPostScriptwithpdf2ps: pdf2psrambaldi_artifacts_for_dummies.pdf lprrambaldi_artifacts_for_dummies.ps

109
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

TheUnixandGNU/Linuxcommandline

Miscellaneous
Comparingfilesanddirectories

110
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Comparingfilesanddirectories
difffile1file2 Reportsthedifferencesbetween2files,ornothingifthe filesareidentical. diffrdir1/dir2/ Reportsallthedifferencesbetweenfileswiththesame nameinthe2directories. Toinvestigatedifferencesindetail,betterusegraphical tools!

111
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

tkdiff
http://tkdiff.sourceforge.net/ Usefultooltocomparefilesandmergedifferences

112
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

kompare
Anothernicetooltocomparefilesandmergedifferences Partofthekdesdkpackage(FedoraCore)

113
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

gvimdiff
Anothernicetooltoviewdifferencesinfiles Availableinmost distributionswithgvim Apparentlynotusing diff. Noissuewithfileswith binarysections!

114
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

TheUnixandGNU/Linuxcommandline

Miscellaneous
Lookingforfiles

115
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Thefindcommand
Betterexplainedbyafewexamples! find.name*.pdf Listsallthe*.pdffilesinthecurrent(.)directoryor subdirectories.Youneedthedoublequotestoprevent theshellfromexpandingthe*character. finddocsname"*.pdf"execxpdf{}';' Findsallthe*.pdffilesinthedocsdirectoryand displaysoneaftertheother. Manymorepossibilitiesavailable!However,theabove2 examplescovermostneeds.

116
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Thelocatecommand
Muchfasterregularexpressionsearchalternativetofind locatekeys Listsallthefilesonyoursystemwithkeysintheirname. locate*.pdf Listsallthe*.pdffilesavailableonthewholemachine locate/home/fridge/*beer* Listsallthe*beer*filesinthegivendirectory(absolutepath) locateismuchfasterbecauseitindexesallfilesina dedicateddatabase,whichisupdatedonaregularbasis. findisbettertosearchthroughrecentlycreatedfiles.

117
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

TheUnixandGNU/Linuxcommandline

Miscellaneous
Variouscommands

118
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Gettinginformationaboutusers
who Listsalltheusersloggedonthesystem. whoami TellswhatuserIamloggedas. groups TellswhichgroupsIbelongto. groups<user> Tellswhichgroups<user>belongsto. finger<user> Tellsmoredetails(realname,etc)about<user> Disabledinsomesystems(securityreasons).

119
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Changingusers
Youdonothavetologouttologonanotheruseraccount! suhyde (Rare)Changetothehydeaccount,butkeepingthe environmentvariablesettingsoftheoriginaluser. sujekyll (Morefrequent)Logonthejekyllaccount,withexactly thesamesettingsasthisnewuser. su Whennoargumentisgiven,itmeanstherootuser.

120
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Thewgetcommand
Insteadofdownloadingfilesfromyourbrowser,justcopyand pastetheirURLanddownloadthemwithwget! wgetmainfeatures httpandftpsupport Canresumeinterrupteddownloads Candownloadentiresitesoratleastcheckforbadlinks Veryusefulinscriptsorwhennographicsareavailable (systemadministration,embeddedsystems) Proxysupport(http_proxyandftp_proxyenv.variables)

121
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

wgetexamples
wgetc\ http://microsoft.com/customers/dogs/winxp4dogs.zip Continuesaninterrupteddownload. wgetmhttp://lwn.net/ Mirrorsasite. wgetrnphttp://www.xml.com/ldd/chapter/book/ Recursivelydownloadsanonlinebookforofflineaccess. np:"noparent".Onlyfollowslinksinthecurrentdirectory.

122
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Misccommands(1)
sleep60 Waitsfor60seconds (doesn'tconsumesystemresources). wcreport.txt(wordcount) 438211518302report.txt Countsthenumberoflines,wordsandcharacters inafileorinstandardinput.

123
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Misccommands(2)
bc("basiccalculator?") bcisahandybutfullfeaturedcalculator.Evenincludes aprogramminglanguage!Usetheloptiontohave floatingpointsupport. date Returnsthecurrentdate.Usefulinscriptstorecord whencommandsstartedorcompleted.

124
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

TheUnixandGNU/Linuxcommandline

Systemadministrationbasics

125
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Networksetup(1)
ifconfiga Printsdetailsaboutallthenetworkinterfaces availableonyoursystem. ifconfigeth0 Listsdetailsabouttheeth0interface ifconfigeth0192.168.0.100 Assignsthe192.168.0.100IPaddress toeth0(1IPaddressperinterface). ifconfigeth0down Shutsdowntheeth0interface (freesitsIPaddress).

126
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Networksetup(2)
routeadddefaultgw192.168.0.1 Setsthedefaultrouteforpacketsoutsidethelocal network.Thegateway(here192.168.0.1)is responsibleforsendingthemtothenextgateway,etc., untilthefinaldestination. routen Liststheexistingroutes
noption:immediatelydisplaysipaddresses insteadoftryingtofindtheirdomain names

routedeldefault orroutedel<IP> Deletesthegivenroute Usefultoredefineanewroute.

127
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Networktesting
pingfreshmeat.net ping192.168.1.1 Triestosendpacketstothegivenmachineandget acknowledgmentpacketsinreturn.
PING192.168.1.1(192.168.1.1)56(84)bytesofdata. 64bytesfrom192.168.1.1:icmp_seq=0ttl=150time=2.51ms 64bytesfrom192.168.1.1:icmp_seq=1ttl=150time=3.16ms 64bytesfrom192.168.1.1:icmp_seq=2ttl=150time=2.71ms 64bytesfrom192.168.1.1:icmp_seq=3ttl=150time=2.67ms

Whenyoucanpingyourgateway,yournetworkinterfaceworks fine. WhenyoucanpinganexternalIPaddress,yournetworksettings arecorrect!


128
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Networksetupsummary
Onlyforsimplecaseswith1interface,nodhcpserver... Connecttothenetwork (cable,wirelesscardordevice...) Identifyyournetworkinterface: ifconfiga AssignanIPaddresstoyourinterface(assumingeth0) ifconfigeth0192.168.0.100(example) Addaroutetoyourgateway(assuming192.168.0.1) forpacketsoutsidethenetwork: routeadddefaultgw192.168.0.1

129
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Nameresolution
YourprogramsneedtoknowwhatIPaddresscorrespondsto agivenhostname(suchaskernel.org) DomainNameServers(DNS)takecareofthis. YoujusthavetospecifytheIPaddressof1ormoreDNS serversinyour/etc/resolv.conffile: nameserver217.19.192.132 nameserver212.27.32.177 Thechangestakeeffectimmediately!

130
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Creatingfilesystems
Examples mkfs.ext2/dev/sda1 FormatsyourUSBkey(/dev/sda1:1stpartitionrawdata)inext2 format. F:force.Executeeven mkfs.ext2Fdisk.img Formatsadiskimagefileinext2format
ifnotarealdevicefile.

mkfs.vfatvF32/dev/sda1(v:verbose) FormatsyourUSBkeybacktoFAT32format. mkfs.vfatvF32disk.img FormatsadiskimagefileinFAT32format. Blankdiskimagescanbecreatedasinthebelowexample: ddif=/dev/zeroof=disk.imgbs=1024count=65536

131
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Mountingdevices(1)
Tomakefilesystemsonanydevice (internalorexternalstorage) visibleonyoursystem,youhavetomountthem. Thefirsttime,createamountpointinyoursystem: mkdir/mnt/usbdisk(example) Now,mountit: mounttvfat/dev/sda1/mnt/usbdisk /dev/sda1:physicaldevice t:specifiesthefilesystem(format)type (ext2,ext3,vfat,reiserfs,iso9660...)
rawdata

(filedescriptors andfilecontents)

mount

file structure

132
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Mountingdevices(2)
Lotsofmountoptionsareavailable,inparticulartochoosepermissions orthefileownerandgroup...Seethemountmanualpagefordetails. Mountoptionsforeachdevicecanbestoredinthe/etc/fstabfile. Thankstothisfile,youjustneedtostatethemountpoint:
#/etc/fstab:staticfilesysteminformation. #<filesystem><mountpoint><type><options> <dump><pass> proc/procprocdefaults 00 /dev/hda3/ext3defaults,errors=remountro 01 /dev/hda4/homeext3defaults 02 /dev/hda2/root2ext3defaults 02 /dev/hda1noneswapsw 00 /dev/hdc/media/cdrom0udf,iso9660user,noauto 00

mountexampleswith/etc/fstab: mount/proc mount/media/cdrom0

133
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Mountingdevices(3)
Youcanalsomountafilesystemimage storedinaregularfile(loopdevices) Usefultodevelopfilesystemsforanothermachine UsefultoaccessthecontentsofanISOcdromimage withouthavingtoburnit. UsefultohaveaLinuxfilesysteminsideafileinaWindows partition. cp/dev/sda1usbkey.img mountolooptvfatusbkey.img/mnt/usbdisk

134
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Listingmountedfilesystems
Justusethemountcommandwithnoargument:
/dev/hda6on/typeext3(rw,noatime) noneon/proctypeproc(rw,noatime) noneon/systypesysfs(rw) noneon/dev/ptstypedevpts(rw,gid=5,mode=620) usbfson/proc/bus/usbtypeusbfs(rw) /dev/hda4on/datatypeext3(rw,noatime) noneon/dev/shmtypetmpfs(rw) /dev/hda1on/wintypevfat(rw,uid=501,gid=501) noneon/proc/sys/fs/binfmt_misctypebinfmt_misc(rw)

135
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Unmountingdevices
umount/mnt/usbdisk Commitsallpendingwritesandunmountsthegivendevice, whichcanthenberemovedinasafeway. Tobeabletounmountadevice,youhavetocloseallthe openfilesinit:
Closeapplicationsopeningdatainthemountedpartition Makesurethatnoneofyourshellshaveaworkingdirectoryin thismountpoint. Youcanrunthefusermv<mountpoint>commandto viewwhichprocessesstillhaveopenfilesinthemounted partition.Youcanalsousethekoptiontokillthese processes.

136
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Fileownership
Particularlyusefulin(embedded)systemdevelopment whenyoucreatefilesforanothersystem. chownRsco/home/linux/src(R:recursive) Makesuserscothenewownerofallthefilesin /home/linux/src. chgrpRempire/home/askywalker Makesempirethenewgroupofeverythingin /home/askywalker. chownRborg:aliensusss_entreprise/ chowncanbeusedtochangetheownerandgroupatthesame time.

137
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Shuttingdown
halt Immediatelyhaltsthesystem. reboot Immediatelyrebootsthesystem. [Ctrl][Alt][Del] AlsoworksonGNU/Linuxtoreboot. Embeddedsystems:youmustuseanimplementationof initandcanspecifyanykeycombinationin /etc/inittab.

138
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Bewareofthedarksideofroot
rootuserprivilegesareonlyneededforveryspecific taskswithsecurityrisks:mounting,creatingdevice files,loadingdrivers,startingnetworking, changingfileownership,packageupgrades... Evenifyouhavetherootpassword,yourregular accountshouldbesufficientfor99.9%ofyourtasks (unlessyouareasystemadministrator). Inatrainingsession,itisacceptabletouseroot. Inreallife,youmaynotevenhaveaccesstothis account,orputyoursystemsanddataatriskifyou do.

139
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Usingtherootaccount
Incaseyoureallywanttouseroot... Ifyouhavetherootpassword: su(switchuser) Inmoderndistributions,thesudocommandgivesyouaccesstosome rootprivilegeswithyourownuserpassword. Example:sudomount/dev/hda4/home

140
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Managingsoftwarepackages(1)
InstructionsforDebianbasedGNU/Linuxsystems (Debian,Ubuntu...) Packagerepositoriesarespecifiedin /etc/apt/sources.list Toupdatepackagerepositorylists: sudoaptgetupdate Tofindthenameofapackagetoinstall,thebestistouser thesearchengineonhttp://packages.debian.orgoron http://packages.ubuntu.com.Youmayalsouse: aptcachesearch<keyword>

141
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Managingsoftwarepackages(2)
Toinstallagivenpackage: sudoaptgetinstall<package> Toremoveagivenpackage: sudoaptgetremove<package> Toinstallallavailablepackageupdates: sudoaptgetdistupgrade Furtherdetailsonpackagemanagement: http://www.debian.org/doc/manuals/apthowto/

142
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

TheUnixandGNU/Linuxcommandline

GNU/Linux:distributionpackages

143
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Howtofindpackages
Debianpackages:http://www.debian.org/distrib/packages Searchbypackageorfilename rpmfind:http://rpmfind.net/ LotsofRPMpackagesforRedHat,Mandriva,Suse...

144
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Identifyingpackages
Whatpackagedoesafilebelongto? Usefultogetmoreinformation,getthecode,findnewer versions,reportissues... DistributionwithRPMpackages: (RedHat,Fedora,Mandriva,Suse...) >rpmqf/bin/ls coreutils5.2.17 Debian,Ubuntu: >dpkgS/bin/ls fileutils:/bin/ls

145
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Informationaboutpackages
Accesspackagedescription,versionnumber,sources,etc. RPMbaseddistributions: rpmqi<packagename> Debian: dpkgs<packagename>

146
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

TheUnixandGNU/Linuxcommandline

Goingfurther

147
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Commandhelp
SomeUnixcommandsandmostGNU/Linuxcommands offeratleastonehelpargument: h (ismostlyusedtointroduce1characteroptions) help (isalwaysusedtointroducethecorresponding longoptionname,whichmakesscriptseasierto understand) Youalsooftengetashortsummaryofoptionswhenyou inputaninvalidargument.

148
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Manualpages
man<keyword> Displaysoneorseveralmanualpagesfor<keyword> manman MostavailablemanualpagesareaboutUnixcommands,but somearealsoaboutCfunctions,headersordatastructures, orevenaboutsystemconfigurationfiles! manstdio.h manfstab(for/etc/fstab) Manualpagefilesarelookedforinthedirectoriesspecifiedby theMANPATHenvironmentvariable.

149
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Infopages
InGNU,manpagesarebeingreplacedbyinfopages. Somemanualpageseventelltorefertoinfopages instead. info<command>
infofeatures:
Documentationstructuredinsections(nodes)andsubsections (subnodes) Possibilitytonavigateinthisstructure:top,next,prev,up InfopagesgeneratedfromthesametexinfosourceastheHTML documentationpages

150
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

SearchingtheInternetforresources(1)
Investigatingissues Mostforumsandmailinglistarchivesarepublic,andare indexedonaveryfrequentbasisbyGoogle. Ifyouinvestigateanerrormessage,copyitverbatiminthe searchform,enclosedindoublequotes(errormessage). Lotsofchancesthatsomebodyelsealreadyfacedthe sameissue. Don'tforgettouseGoogleGroups: http://groups.google.com/ Thissiteindexesmorethan20yearsofnewsgroups messages.
151
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

SearchingtheInternetforresources(2)
Lookingfordocumentation Lookfor<tool>or<tool>pagetofindthetoolorproject homepageandthenfindthelatestdocumentation resources. Lookfor<tool>documentationor<tool>manualin yourfavoritesearchengine. Lookingforgenerictechnicalinformation WikiPedia:http://wikipedia.org Lotsofusefuldefinitionsincomputerscience.Areal encyclopedia!Opentoanyone'scontributions.

152
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Traininglabs
Traininglabsarealsoavailablefromthesamelocation: http://freeelectrons.com/docs/commandline Theyareausefulcomplementtoconsolidate whatyoulearnedfromthistraining.Theydon'ttell howtodotheexercises.However,theyonlyrely onnotionsandtoolsintroducedbythelectures. Ifyouhappentobestuckwithanexercise,thisprovesthatyou missedsomethinginthelecturesandhavetogobacktothe slidestofindwhatyou'relookingfor.

153
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Thanks
TotheOpenOffice.orgproject,fortheirpresentation andwordprocessortoolswhichsatisfiedallmyneeds. TotheHandhelds.orgcommunity,forgivingmeso muchhelpandsomanyopportunitiestohelp. TothemembersofthewholeFreeSoftwareandOpen Sourcecommunity,forsharingthebestofthemselves: theirwork,theirknowledge,theirfriendship. Topeoplewhosentcommentsandcorrections: TylerLe,LaurentThomas,JeffGhislain,LeifThande, FrdricDesmoulins,PrzemysawCiesielski

154
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Relateddocuments
AllthetechnicalpresentationsandtrainingmaterialscreatedandusedbyFree Electrons,availableunderafreedocumentationlicense(morethan1500pages!).
http://freeelectrons.com/training IntroductiontoUnixandGNU/Linux EmbeddedLinuxkernelanddriverdevelopment FreeSoftwaretoolsforembeddedLinuxsystems AudioinembeddedLinuxsystems MultimediainembeddedLinuxsystems http://freeelectrons.com/articles AdvantagesofFreeSoftwareinembeddedsystems EmbeddedLinuxoptimizations EmbeddedLinuxfromScratch...in40min! LinuxUSBdrivers RealtimeinembeddedLinuxsystems IntroductiontouClinux LinuxonTIOMAPprocessors FreeSoftwaredevelopmenttools JavainembeddedLinuxsystems IntroductiontoGNU/LinuxandFreeSoftware Linuxandecology What'snewinLinux2.6? HowtoportLinuxonanewPDA

155
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

Howtohelp
Ifyousupportthiswork,youcanhelp... Bysendingcorrections,suggestions,contributionsand translations Byaskingyourorganizationtoordertrainingsessions performedbytheauthorofthesedocuments(see http://freeelectrons.com/training) Byspeakingaboutittoyourfriends,colleagues andlocalFreeSoftwarecommunity. Byaddinglinkstoouronlinematerialsonyourwebsite, toincreasetheirvisibilityinsearchengineresults.

156
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com

EmbeddedLinuxTraining UnixandGNU/Linuxbasics Linuxkernelanddriversdevelopment RealtimeLinux uClinux Developmentandprofilingtools Lightweighttoolsforembeddedsystems Rootfilesystemcreation Audioandmultimedia Systemoptimization

FreeElectronsservices
CustomDevelopment Systemintegration EmbeddedLinuxdemosandprototypes Systemoptimization Linuxkerneldrivers Applicationandinterfacedevelopment

Consulting Helpindecisionmaking Systemarchitecture Identificationofsuitabletechnologies Managinglicensingrequirements Systemdesignandperformancereview

TechnicalSupport Developmenttoolandapplicationsupport Issueinvestigationandsolutionfollowupwith mainstreamdevelopers Helpgettingstarted

http://freeelectrons.com

You might also like