thecursorispromptingyoutotypea command.Commands
inLinuxare sometimesreferredtoasbinaries,whichsimply
meansthatthey’re pre-compiledcode.Theyrunina terminal
session,butsomecandetachfromthesessionandruninthe
background,waitingforaneventtotriggerthem.Thistypeof
commandissaidtoberunningasa daemon.
Scriptsare essentiallytextfilesthatcanberunasan
executableprogram.Theyconsistofa seriesofcommands
combinedusingtheshell’s commandsyntaxtocarryoutmore
complextasks.
OneimportantdifferencebetweenLinuxandtheWindows
DOSshellisthatLinuxiscasesensitive.Commandsare almost
alwayslower-caseonly, butfilesordirectoriesmaynotbe,
so/home/Picturesisdifferentto/home/pictures,forexample.
Thisiseasytoforgetatfirstandcan§leadto‘commandnot
found’or‘nosuchfileordirectory’errors.
Anothercommonproblemis‘permissiondenied’when
tryingtousea command.Thisisusuallyeitherbecauseyou
donothavepermissiontoexecutethecommandoryou
donothaveaccesstofilesyouare tryingtomodify. Many
commandsrequire rootaccess.Aswellasbeingthebaseof
thedirectorytree,rootistheallpowerfulsuperuser, whocan
accessallareas(ofwhichmore later).
FindingYourWayAround
Navigatinga filesystemwithouta GUIcanbeconfusingatfirst.
Thefilesystemisconsideredtobeshapedlikea tree.The
baseofthesystemistheroot,andthisbranchesinto...er,
directories.Directoriescancontainfilesandotherdirectories.
Thetreeanalogyisthentotallylost,asa directorycontaining
otherdirectoriesisknownastheparent,andthedirectories
itcontainsare calledchilddirectories.Theforwardslashis
usedtodenotea steponthepathtoa particularfile.The
rootdirectoryisdesignatedbya singleforwardslash( / ) and
shouldonlycontaindirectories.Eachstepdeeperintothe
directorytreeismarkedwitha furtherforwardslashthus:/
var/log/test/test.log.
Bydefault,whenyoulauncha shellsession,youwillbe
inyourownhomedirectory, whichwillbe/home/<youruser
name>(e.g./home/fred).
Thelsandcdcommandscanbeusedtofindyourway
aroundthefilesystem,andI suggestyoutrytheseoutto
familiariseyourselfwithyournewdomain.
ls(list)isusedtoviewthecontentsofthecurrentdirectory,
showingallfilesandsubdirectories.Itcanalsobeusedto
displaythecontentsofa differentdirectory(e.g.ls/etcwill
listthecontentsofthe/etcdirectory).
Someshellsindicatethetypeoffilesina directoryby
colours.Forexample,inmyshell,executablesare green,text
filesare white,anddirectoriesare blue.
cd(changedirectory)isthecommandusedtomovearound
thefilesystem.Itcanbeusedtomoveupanddownthe
filesystemtreeortojumptoanotherlocationwithinit.Typing
cdonitsownwillreturnyoutoyourhomedirectory. cd/ will
takeyoudirecttothe/ (root)directory, andtypinga pathwill
takeyoudirectlytothedirectoryattheendofit(e.g.cd/var/
logwilltakeyoutothelogdirectoryinside/var).
There are severalabbreviationsthatare useful:
..representstheparentdirectory, socd..willmoveyouup
onestep.
- representsthepreviousdirectory, socd- jumpsbackto
where youjustcamefrom.
./representsthecurrentdirectoryandisusedforexecuting
commandswithinthecurrentworkingdirectory(e.g../
installscriptorsudo./installscriptwillrunthecommand
installscriptwithinyourcurrentworkingdirectory).
~representsthehomedirectoryofthecurrentlylogged-in
user, socd~/PictureswilltakeyoutothePicturesdirectoryin
yourownhomefolder.
Whenyougetlost,a usefulcommandispwd(print
workingdirectory),whichwilldisplaythefullpathofthe
directorythatyouare currentlyworkingin(e.g./var/log/
www).
CommandUsage
ThoseofyouwhohaveusedDOSwillseesomesimilaritiesin
theLinuxshell.Bothofthemare basedhistoricallyontheUnix
commandline.
Whenyoutypea command,theshellwillsearcha seriesof
directoriesinturnandexecutethefirstmatchingcommand
thatitfinds.This meansoncea commandisinstalled,just
typingitsnameatthecommandpromptwillrunit.
iVariousstylesofdirectorylisting:ls,ls -l andls -a
Navigating a files ystem
without a GUI can be
confusing at first