You are on page 1of 8

Uni

xBas
ics

Hi
sto
ry
ThefirstversionofUni xwa sdeve lopedb yBe l
lLa bs( par
tofAT&T)i n1969,ma ki
ngitmor ethan
fort
yy earsolda ndoneoft hefewc a sesofac omput e rtechnologythatha ssurvi
vedmor ethana
decade .I
tsrootsgoba cktowhe ncomput erswe r
el a
r gea ndrare,ti
meont hemv eryexpensi
vea nd
sharedbe tweenma nyusersUni xwa sde s
ignedfrom t hebe gi
nning1 t
oha vemul t
ipl
euserswor k
ing
simultaneousl
y.Whi l
ethismights eems t
rangea ndunne cess
aryinawor l
dwhe reevery
oneha sthe i
r
ownl aptop,comput i
ngisa gai
nmov ingba cktor emot ec entra
ls er
vic
eswi t
hma nyuser
s:thec ompute
powe rrequir
edf orma ppingnext-gene rat
ions e
que nci
ngda taordenov oassemblyisbeyondwha tis
avail
ableorde si
ra bl
et ohavesitti
ngony ourl a
p.Inma nywa ys,theCloud(orwha teverhasreplace
d
i
tb yt het i
mey our eadthis)requir
eswa ysofwor kingt hataremor einc ommonwi thtr
aditi
onalUnix
ma chinesthant hepe rs
onalcomput inge mpha si
sedb yWi ndowsa ndAppl eMa ci
ntosh.
USAf ede r
almonopol ylawp r
eventedAT&T f rom c omme rci
ali
si
ngUni xbutinte r
e stinus ingit
i
nc reasedout si
deofBe llLabsa nde ventual
lytheyde ci
de dtogi v
eita wa yfreel
y,i
nc ludingt hes ource
code ,whicha l
l
owe dot heri
ns t
ituti
onst omodi f
yi t.Perhapsthemos timpor ta
ntoft he s
ei nstit
utions
wa st heUni ver
sityofBe rkel
ey2
whichdistri
butedas etoft oolstoma keUni xmor eus e f
ula ndma de
cha ngestha tsignific
ant l
yincreasedpe rf
orma nce.Thei nvolv
eme ntofs everaluniversi
t i
esini ts
deve l
opme ntme antUni xwa sideal
lyplac e
dwhe nt heinternetwa screa t
eda ndma nyoft he
funda menta ltechnologi e
swe rede v
elopeda ndt estedus i
ngUni xma chines.Againt hesei mp roveme nt
s
we regivena wa yfre el
y,someoft hec odebe i
ngr epurposedtop rovi
de dne tworki
ngf ore arlyv er
sionsof
Wi ndowsa nde vent oda yseveraluti
li
tiesinWi ndowsVi s
taincorpora
t eBe rkel
eycode 3
.
Aswe llasbe ingakeypartint hedeve
lopme ntoftheearlyint
ernet
,aUni xma chinewasa l
sot he
firs
twe bs erv
er,aNe XT cube.Ne
4
XT wasane arl
ya t
temptt oma keaUnixma c
hinefordesktopuse,
ex t
remelya dvanc e
dfori
tstimebuta l
soveryexpensi
vesot heyneverrea
ll
yc aughtonout si
deoft he
financeindustry.Appl
ee v
entuall
yboughtNe XT,i tsoper
ati
ngs yste
m becomingOs X,a ndthis
he r
ita
gec a
ns ti
llbeseeninitsprogramminginterf
aces.Appleisnowthelargestma nufac
turerofUnix
ma chine
s ;everyApplecomput er
,t hei
Phonea ndmos trecentiPodshaveaUni xba s
eunde r
ne at
h
theirfacade.
Byt heea
rly90sUnixbecameincr
ea s
ingl
yc ommerci
al
lyimporta
ntwhic
hinev
itablyleadtole
gal
t
rouble
:wit
hs oma nypeopl
egivi
ngawa yimp r
ovementsfr
eel
ya ndhavi
ngthe
mi nt
e grat
edintothe
s
ystem,whoa ct
ual
lyownedit?Thele galtr
oublecas
tuncertai
ntyove
rthefr
eel
yav ail
abl
eUnix
v
ersi
ons,cr
eati
nga nopeni
ngforanotherfreeoper
ati
ngs y
stem.
Thev
acuum wa
sfil
l
edb
yLi
nux
,af
ree
lya
vai
l
abl
ecomput
erope
rat
ings
yst
em5 s
imi
l
art
oUni
xand
1 Thisislie.Int ruth,Unixactual
lygrewoutofade si
ret opl
ayaga mecal
ledSpaceTr av
el
htt
p://e n.wikipedia.
org/wi
ki/Space
_Tra v
el_(vi
deo_ga me)a ndthefeat
urestha
tma dei tanoper
ati
ng
sys
tem we r eincidental
.Ini
ti
all
yitonlys
upportedoneus erandt henameUnix,ori
gina
ll
yUNICS,i
san
unf
o r
tuna tepunonMULTICS,amul t
i-
usersys
tema va
il
a blea
tt het i
me.
2 As i
gnificantp roport
ionofMa cOs Xhasitsrootsi
nt heBe rk
e l
eyStanda
rdDistr
ibuti
on( BSD).
3 Forexa mpl e:s trings ftp.exe | grep Cal
@(#) Copyright (c) 1983 The Regents of the University of California.
4 Seehttp://e
n.wikipedi
a.org/wi
ki
/NeXT
5 Morec orr
ectl
y,Linuxisjusttheker
nel
,thec
entr
alpr
ogramfr
om whi
challot
her
sarer
un.Ma nymor
etool
s
i
na ddi
tiontot hi
sa rerequir
edtomakeanoper
ati
ngsys
tem,tool
spr
ovi
dedbytheGNUp r
oje
c t
.
ht
tp://www. gnu.
o rg/.
sta
r tedb yLinusTorva l
dsin1991a sahobb y.Importa nt l
y,Linuxwa swr i
ttenf r
om s cr
atcha nddidnot
cont ainanyoft heori
ginalUni xcodea nds owa sfreeofl egaldoubt .Coi nc i
dingwi ththepe net
ration
oft hei nt
ernetontouni v
ersi
tyc ampusa ndt hea v
a i
l
a bil
ityofc he apbuts uffici
ent l
ypowe r
fulpersonal
comput er
s,Linuxrapi
dlyma t
ure dwithov eronehundr edde velopersc ollaborati
ngov erthei nt
ernet
withint woy ear
s.Ther ealadva ncesdrivingLi nuxwe res ocialr
a thert hant e
chnol ogical
,disparat
e
vol
unt eer
sdona t
ingti
meont heunde rsta ndingtha t
,i nr eturnf orgivingt he i
rwor ka wa yfreel
y,
anyt hingbasedont heirworkisa lsogiv ena wa yfree
lya nds ot heyint urnbe nefitf r
om imp rove
me nts.
Thei deathatunderpinsthissha r
inga nde nsuresthatnobodyc anp rofitfrom a ny oneelse'
swor k
withouts hari
ngi s
cop yl
eft
,de scri
bedi nas implelega ldoc ume ntc alledt heGNUGe neralPubli
c
Licenc ehttp:
//www. gnu.org/cop yl
eft
/ whi
6
c hturnst henot i
onofc op yri
ghtoni tshe ad.
Today
,Linuxha
sbe c
omethedomi
nantf
reeUni
x-l
i
keope
rat
ings
yst
em wi
thmi
l
li
onsofus
ersa
nd
s
upportf
rom manyla
rgecompa
nie
s.

Ge
tti
nga
ndi
nst
all
i
ngUbunt
u
Thistutori
alconcentr
ate sontheUbuntudist
ri
buti
on(pac
k agi
ng)ofLi
nux,whichisoneoft he
mostwidel
yus ed,butallthee x
amplesar
efairl
ygener
icandshouldworkwit
hmos tLinux,Uni
xa nd
Macint
oshc omputers
.The rea r
ema nydi
ffe
rentgui
desonthewe babouthowtoinstallUbunt
ubut
werecomme ndinstal
l
ingita sav i
rt
ualmachineonyourc
urrentcomputer
,seese
pa r
ate
doc
ume nta
t i
onforinstr
uctions.
TheUbunt uLinuxdi
stri
buti
onisge ne r
all
yea s
yt ouseanditisupdate
d( f
orf ree
)e verysixmonths.
Atthetimeofwr i
ti
ng,thecurre
ntve rsionofUbunt uis11.
10,name daft
eri tsreleas
eda teinOc tobe
r
2011,anda l
soknownasOne i
ri
cOc elot
;thene x
tv e
rsi
on,12.04orPreci
s ePa ngol
inwillbe
rel
eas
edinAp ri
l2012andwi l
lbedesigna tedaLongTe r
m Support(LTS)e dit
ion,me a
ningthatitwil
l
berecei
vefix
esandma i
ntenanceupgra desforfiv
ey ea
rsbefor
ebe i
ngreti
red,a ndist hebe s
topti
oni f
youdon'twanttoberegular
lyupgradingy oursyste
m.

Ac
cli
mat
isa
tion
As ignificantefforthasbeenunde rtakent oma keUbunt ueasyt ous e,soe vennov i
cec omput er
user
ss houldha vel i
ttl
et r
oubleusingit.The reisac onsiderabl
enumbe roftutorialsa v
ail
a bleforuser
s
newt oUbunt u;theoffici
alma ter
ialisavaila
blea tht tps://hel
p.ubunt u.c
om/11. 10/butaqui ck
sear
c hont hewe bwi l
llocat
emuc hmo re.Ina dditi
on,t he r
eisal otofdoc ume ntationinsta l
le
dont he
ma c
hi neits elf
:youc a nacces
st hi
sb ymov ingt hemous et owardsUb untuDe sktopa tthet opl e
ftof
thes creena ndcli
ck i
ngont hehe l
pme nut hata ppears.Inge neral
,t hena meoft hep r
ogra my ouare
curr
e ntlyus ingisdi s
playe
da tthet op-l
eftoft hes creena ndmov i
ngt hemous et ot opoft hescree
n
wil
lre vealt hep r
ogr amsme nusinas i
milarfashiont ohowt heya redi spl
ayedont heMa c( alt
hough,
confusingly,s omep r
ogramsdispla
yt heirme nuswi thinthe i
rownwi ndowr at
herl i
k eaWi ndows
comput er
).
Ana lt
erna
tiv
ewa ytoge thelpistocl
ickontheci
rcul
arsymbol(asty
li
sedpi
ctur
eoft hreepe
ople
hol
dinghands)att
het opleftoft hes
cre
ena ndty
pehe l
pinthesea
r c
hboxthatappea
rs.Forwa ntof
abettername,wewillre
fert othepeopl
e-hol
di
ng-
handsbutt
ona stheUbuntubutt
onalthoughthe
hel
pt e
xtthatappe
arsde s
cribesitasDas
hhome
.
Ubuntucomesfre
ewithma nyt ool
s,inc
ludingwebb r
owser
s ,fil
emanager
s,wordproc
essor
s,et
c.
Genera
ll
yther
eisafreeequi
valentformosts oft
wareyoumightus eandyoucanb r
owsethose
av
a i
l
ablebycl
ic
kingontheUb untuSoftwareCe ntr
e,whoseicona tthel
eftofthescr
eenlooksl
i
kea
6 I
tshoul
dbenot
edt
hatt
heGNUp
roj
ect
,andt
hephi
l
osophybe
hindi
t,p
reda
teLi
nuxb
yal
mos
tade
cade
.
shoppingba gfullofgoodie
s.TheUbuntuSoftwar
eCe nt
reisjustastar
ti
ngpointa ndt herea
remany
others ourc
esa v
a i
la
ble,bothofpr
epac
k a
gesoftwar
especi
fic
all
yforUbuntuands ourc
ec odet
hatwi
ll
requi
rec ompil
ing.Se a
rchthewebforUbunt
us of
twar
ereposit
ori
esf
ormoreinformationonobtai
ning
addit
iona ls
oft
wa re.
Whi lethe reareexpl
ici
tkeycombi
nati
onsf orcopyandpa s
tingtex
t,justl
ik
eonWi ndowsorMa c,
shi
ft-
control -
ca ndshif
t-c
ontr
ol-
vinUbunt u,thi
sconvent
ionisnotrespect
edbya l
lp r
ograms.Uni
x
hastradit
iona l
lybeenmor emousecent
redwi ththelef
tmousebut t
onus edtohi
ghlighttextandthe
middl
ebut t onus e
dt ocopyit
.Youma yfindyoursel
facci
dentall
ydoi
ngt hi
socca
sionall
yifyouare
n't
usedtous ingt hemiddlemousebutt
on.
Star
ti
nga ppli
cati
onsfr
om icons,openingfol
ders,etc
...onlyrequi
resasingl
ec l
ic
k,ratherthant he
doubl
ecli
ckrequire
donWi ndows ,makingthea c
tionofp ress
ingbuttonsands el
ect
ingthingsfr
om
menusmorec onsi
stentwi
theac hother.Acci
dentall
ydoublec l
ick
ingwillgener
all
yresul
tina nac ti
on
bei
ngdonetwic e
,notnormall
yaba dthingbutitdoe sme ansthatimpati
entuserscanquicklyfind
thei
rdes
ktopc over
edinwindows.
Pe rhapsthemos timport antdi
ffer
enceyoua r
eli
kel
ytoencounteronada i
l
ybasi
sisthatthe
name soffil
esa nddir
ectori
e sarecasesens
iti
ve:README.txt
,r e
adme .t
xtandre
adme.TXT allr
efe
r
todiffer
entfil
es.Thisisdiffere
ntfrom bot
hWi ndowsandMacOs X7,wher
euppera
ndl ower
-cas
e
char
a cter
sarep re
serve
di nt henamebutt hefil
ec a
nberef
err
e dtous i
nganycas
e.

Fe
tchi
ngt
hee
xampl
es
Therea remanyexa
mpl esi
nt hi
st utor
ialtobetr
ied,encl
ose
dinbox esl
iket
heonebelo
wwhich
expla
inst hefor
matofthee xamples.Thefile
srequi
redfortheexa
mpl e
sc a
nbedownloa
dedfrom
http:
//tinyurl
.c
om/32a2gbk/uni
x .
tgza l
thoughtheexamplebel
ows howshowtoautomati
cal
l
y
downloada ndunpackthefil
ereadyf oruse.
# Ordinary text, starting with a # and indented on the first line, is a comment
# on the example.
Bold text is something to type in at the command-line. A single
line wrapped on to multiple lines is indicated by the ' ' symbol
This is now a separate command.
Italic text is a reply from the computer to what was typed in
# Now we will download and install the examples
# Firstly, ensure that we are in the home directory
cd
# Where an example requires you to be in a specific directory, it will start
# with the command and reply to tell you where you should be. If you are not
# in the correct directory, move to it before doing the example (see later for
# how to change directory. Here 'ebi' is just the name of the user (you),
# yours may vary.
pwd
/home/ebi/
# Download and unpack the examples. You don't need to understand what this is
# doing yet, although you will by the time you have worked through this
# document.
wget -O - 'http://tinyurl.com/32a2gbk/unix.tgz' | tar -zx
# If you are trying the examples out on a Mac, the command wget is not

7 De
spi
teit
sUnixher
ita
ge.Thi
sbe
hav
iouri
sde
li
ber
atet
oma
int
ainc
ompa
tibi
l
itywi
the
arl
i
erv
ers
ionsoft
he
Macope
rati
ngsy
stem.
# available and the above will not work. Instead, use the similar curl command
curl -L 'http://tinyurl.com/32a2gbk/unix.tgz' | tar -zx
# A directory `examples' should have been created.
ls examples/unix
CompressionLineEndings MultipleFiles SCP haiku
Escaping MoveCopy Pipes Scripting
# How to delete the examples, if required
# Firstly, ensure that we are in the home directory (where the examples where
# installed).
cd
rm -rf examples

Thec
omma
ndl
i
ne
Whi l
eUbunt uhasa l
lthegr a phi
caltoolsy oumi ghte xpectinamode rnope rati
ngs yste m,s one w
usersra r
e l
ynee dtodea lwithitsUni xfounda tions,wewi llbewor ki
ngwi ththec omma nd- line.An
obviousque sti
oni swhyt hec omma nd-l
ineiss til
lthema inwa yofi nter
acti
ngwi t
hUni xor ,mor e
rel
evant l
y,whywea rema k
ingy ouus ei t?Pa rtoft hea nswe rtot hefir
stquestionist hatt heor i
ginsof
Unixp reda t
et hedevel
opme ntofgr aphicalinterf
a c
e sandt hi
si swha tal
lthetool sandp rogr amsha ve
evol
v edf rom.Ther easont hec omma nd-li
ner ema i
nspopul aristhatitisane xtreme l
ye fficientwa yto
i
nterac twi t
ht hecomput er:onc eyouwa ntt odos ome thingc omplexenought hatt herei sn' taha ndy
buttonf orit,graphi
calinterfac
e sforcey out ogot hroughma nyme nusandma nual
lype rform at ask
thatc ouldha vebeena utoma ted.Alternativel
y,y oumus tr es
orttos omef orm ofp r
ogr ammi ng(Ma c
Os XAut oma t
or,MicrosoftOffic ema cros,etc)whi chi st hemor alequiva
lentofus i
ngt hec omma nd-
l
ine.
Unixisbui
ltaroundma nylit
t l
etool
sde si
gnedt oworkt ogethe
r.Eachprogram doe sonet as
kwe l
l
andreturnsitsoutputinaf or
me as
il
yunde r
stoodb yotherp r
ogramsandthesep r
ope rti
esa l
l
ows i
mple
progr
a mstobec ombi nedtogethertoproducec omple
xr e
sults,rat
herl
ikebuil
dings omethingoutof
Legob ri
cks.Thef or
wa r
dtot he1978r e
por ti
nt heBe l
lSys t
em Te c
hni
calJournal
8
descri
bestheUnix
phil
osophya s
:
"(
i)Ma k
eeac
hp r
ogr
am doonethi
ngwe
ll
.Todoane
wjob,bui
l
daf
res
hra
the
rtha
ncompl
i
cat
e
ol
dprogr
amsbyaddi
ngnewfea
ture
s.
(i
i
)Ex pectt
heout putofever
yp r
ogramtobe c
ometheinputtoanothe
r,asyetunknown,pr
ogr
am.
Don'
tclutt
eroutputwithextr
aneousinf
orma
tion.Av
oidst
ringe
ntl
ycolumnarorbina
ryinputf
ormat
s.
Don'
tinsi
stoninter
ac t
ivei
nput.
(i
ii
)De
signandbui
lds
oft
wa r
e,eve
noperat
ingsyst
ems,t
obet
ri
ede
arl
y,i
dea
ll
ywi
thi
nwe
eks
.Don'
t
he
sit
atetothr
owa wa
ytheclumsypart
sandrebui
l
dt he
m.
(i
v)Us
etool
sinp
refe
renc
etounsk
il
le
dhe l
pt ol
i
ghte
nap r
ogra
mmi ngtask
,e v
e ni
fyouha
veto
de
tourtobui
l
dthetool
sandex
pecttothr
ows omeofthe
m outaf
teryou'
vefini
shedusi
ngt
hem.
"
Ther
estoft
histut
oria
lwillbeba
sedus
ingthec
omma nd-
li
nethr
oughater
mina
l9
.Thet
ermina
l
p
rogr
amcanbefoundb ycli
cki
ngontheUbunt
ubuttona
ndt ypi
ngter
mina
linthes
ea rc
hbox,as

8 See:M. D.Mc Il
roy
,E.N.Pins
on,andB. A.Tague"UnixTime-Sha
ringSy
ste
m For
ward",TheBel
lSyst
em
TechnicalJounal
,July-Aug1978v ol57,number6part2,pg.1902
9 Terminologythatdatesbacktothee ar
lyday
sofUnixwhe nther
ewouldbemanyt
e r
minal
s
,ba
sic
all
ya
fa
ncys creenandk ey
board,conne
ctedtoac ent
ralc
omput e
r.
showni
nIl
lus
trati
on1.Onceopen,thet
extsi
zecanbechangedus
ingtheVi
e om me
w/Zo nuopt
ions
orthef
ontchangedent
ir
elyus
ingtheEdi
t/Pr
ofil
ePre
fer
encesmenuopti
on.
Whi l
ewea r
eus i
ngLi nuxduringthewor kshop,y ouma ynotha v eac c
e s
stoama c
hinela t
erorma y
notwi sht ouseLi nuxe xcl
usi
velyony ourcomput er.Whiley oucouldinstal
lLinuxa s'dual-
boot'on
yourc omput er
,orr uni tinav i
rtualma c
hine ,t
10
hek nowledgeoft hec omma nd-li
neisfair
ly
transf
e r
ablebetwe enpla tf
orms:ha vi
ngUnixf ounda ti
ons,Ma cOsXa lsoha sac omma nd-l
inehidden
awa y:/Appl i
cations/Ut i
li
ti
es/Terminaland,wi thas ma l
lnumbe rofe ccentri
ci
ties,ever
ythingthat
wor k
sont heLinuxc omma nd-l
ineshouldwor kf orOs X.Wi ndowsha sitsowni ncompa ti
blevers
ionof
ac omma nd-l
i
nebutCy gwinhttp://www.cygwi n.com/c anbei nstal
leda ndprovidesane ntir
eUnix-
li
ke
envir
onme ntwithinWi ndows .

Il
lustrati
on1:Op eningaterminalinUb untu.A p art
ial
lyobscuredt ermi naliss hownatt heb ot
tom
ri
g htofthede sktop.
Att hebe gi
nni ngoft hecomma nd-l
ineist hec omma ndp r
ompt ,s howingt hatt hec omputerisready
toa cceptc omma nds.Thepromptistextoft hef or
m user@computer:directory$,I l
lus
trati
on1
hav i
ngaus erc all
e dtiminthedire
ctor
y~onac omputercall
edc offee-gri
nder.Ha vi
nga l
lthis
i
nforma ti
oni sha ndywhe nyoua r
ework i
ngwi thmul t
ipl
eremotec omput ersatt hes amet i
me .The
prompti sc onfigur abl
eandma yvarybe t
we enc omputer
s;youma ynot i
cel aterthatot herpromptsare
sl
ightlydiffer
ent .Someba s
iccomma ndsa res howni nTable1;t r
yt ypingt hema tthec omma nd-l
ine
11

p ressreturna f
te rthecomma ndtote l
lthec omputertorunt hec omma nd.

10AVirtualMachi
ne( VM)isap r
ogram onyourcompute
rthatactsli
keanothe
rc omputerandcanr
unother
oper
atingsys
tems.Sever
alVM' sar
eav a
il
abl
e,Vir
tual
Boxhttp:
//www. v
irt
ual
box.or
g/isfreeandr
egul
arl
y
updat
ed.
11You'
llnoti
cethattheoutputofpwddoesnotagreewitht
hec omma ndprompt,ins
tea
dp ri
nti
ng
/home/ebi. Thisisbecause~isasynonymfor/home/ebi,s eeTable2formo r
ede t
ail
s.
whoami Yourus
erna
me
hostname Na
meofma
chi
nebe
ingus
ed
pwd Cur
rentdi
rec
tor
y(Pr
intWor
kingDi
rec
tor
y)
uname Ope
rat
ings
yst
em(
uname -af
ort
hef
ullde
tai
l
s).

Tabl
e1:Someb as
iccommandstoanswertheimpor
tantq
ues
tionsofl
if
e:
whoam I
?,
whe
ream
I?
,andwhatoper
ati
ngsy
stem am Irunni
ng?

Fi
l
esa
nddi
rec
tor
ies
Allfil
esinUni xarea rrange dinat re e-l
ikes tr
ucture
:dire
ctori
esa r
er epre
s e
nte dasbranchesleading
fr
om as ingl
et runk( t heroot)a ndma y,int urn,haveotherbranchesleadi
ngf rom them(di r
ectories
i
ns i
dedi rect
or i
e s
)a ndi ndi
v i
dua lfil
esar ethel eavesofthetree.Thet rees t
ructureissi
mila
rt ot hatof
everyot hercommonope ratings ystema ndmos tfil
ebrowserscandispla
yt hefil
e sys
teminat r
ee-lik
e
fa
s hi
on,f orex ample :pa r
toft hefil
esyste mf ora nUbuntuLinuxc omput e
ri sdispla
yedinIl
lustr
at i
on2.
Whe reUni xdi ffer
sf rom othe rope rat
ings yste msisthatthefil
esyste
mi sus edmuc hmorefor
organis
ingdi fferentty pesoffiles:thee ss e
ntials y
stemp r
ogramsa realli
n/bina ndthei
rsha r
edc ode
(l
ibrari
es)a r
ei n/lib;s i
milarl
yus erp rogramsa rein/usr/bin,withlibrar
iesin/usr/liba ndma nual
pagesin/usr/share/man.
The rearetwodi
ffer
entwa y
sofspecif
yi
ngt helocati
onofafil
eordi
rect
oryi
nt hetree
:the
absolut
epa t
ha ndt
her el
ati
vepathfr
om whe rewec urre
ntl
yare(t
hecurr
entworki
ngdirect
ory
,se
e
pwd,p r
evi
ously
)inthefil
esy
stem.Ana bs
olutepathisonethatstar
tsa
ttheroota nddoesnotde
pend
ont heloc
ationoft
hec urr
entworki
ngdirect
ory.Sta
r t
ingwit
ha/t osi
gnif
ytheroot,thepath

Il
lust
r at
ion2:Tree-l
ikes
truct
ureoftheUb untufil
esy
stem.Start
ingattheroot'/'
,dire
ctorie
sar
e
di
s pl
ay e
dandt hehomeandhome /t
im di
rect
orie
shav ebee
nop enedtoshowitsconte
nts,
rel
ationshi
psindic
atedbyindent
ion./home/ti
mc ont
ainssev
eralmoredire
ctori
eswhichc oul
dal
so
beope ned.
describesallthedi rec
tor
ies(br
anches)wemus ttrave
r s
et ogettot hefil
e,eachdirec
toryname
separa t
edb ya/.Fore x
ample,/home/user/Music/TheKinks/SunnyAfternoon.mp3r efer
stot hefil
e
Sunny Afternoon.mp3i nsi
dethedirec
toryThe Kinks,whi chisinsi
det hedire
ctoryMus i
c, ,whichis
i
ns i
deont hedi rector
yhome ,whic
hisc onnect
e dtot her oot.Ifyoua r
ef a
mi l
i
a rwi
thMi cr
osof
t
Wi ndows ,youmi ghtnoti
cethatthepa t
hs e
pa rat
orisdi ffe
rent:aforward-s
lash/r at
herthanthe
bac kward-sl
as h\onWi ndows;thepathsofwe bpa gesa rea l
soseparatedbyf orwa
rd-s
las
hes,r
e v
e a
li
ng
theirUni xoriginsasapa thtoafileonar emot ema chine .
Forc
onv
enienc
e,afewdir
ect
ori
esha
ves
pec
ials
ymbol
stha
tar
esy
nony
msf
ort
hema
ndt
hemos
t
c
ommonoft he
sea r
eli
ste
dinTabl
e2.
Sy
mbol De
scr
ipt
ion Not
es
/ Rootdi
rec
tor
y Got
otopoft
ree
. Cur
rentdi
rec
tor
y
.. Thepa
rentdi
rec
tor
y Gouponei
ntr
ee
~ Homedi
rec
tor
y Sy
nony
mfor$HOME
~user Homedi
rec
tor
yforuser

Table2:Spe c
ialdi
rectoryname s
.Mostoft hetheseareonlyhaveaspecia
lmeaningwhe natt
he
begi
nningofapa th,ot her
wisetheyar
ejustas ymbol.Forexample
,dir/~/isthedirect
ory~ i
nsi
de
thedirec
torydirint hec ur
rentdir
ect
ory
,whe reas~/dir/isthedir
ect
orydirinsidethehome
dir
ector
y.Inbothc as
e sthe'/'symbol
sares epa
rator
sr at
herthantherootdi
rec
to r
y.

Thec ur r
entl ocati
on,t hewor k i
ngdi rector
y,c anbedi splayedatt hec omma nd-l
ineus ingthepwd
comma nd.Ra the rthanr efe
rri
ngt oafileb yitsa bsol
utepa th,wec anr eferitb yusingapa threlati
ve
towhe rewea re:afil einthec urre ntdirector
yc anber e f
er redtobyi tsna me ,afilei nadi rector
y
i
nsideourwor kingdi rect
oryc anber eferredtob ydirectory/filename( a nds oonf orfilesi
ns i
deof
dir
e c
toriesinsi
deofdi rect
oriesinsideofourwor ki
ngdi r
e ctory,et
c...).Not et hatthe sepa thsarev ery
si
mi l
art ohowwede scri
bea bsolutepa thse xceptthatt heydonots tar
twi th/;a bsol utepathsare
rel
ativepa thsrelativetot heroot( al
ternativel
ywec oul
dr e adthei niti
al/a sgotor ootandc onsider
themt ober el
a tivepa t
hs).Ass howni nTa bl
e2,t hedir e
c toryabov ethec urre
ntdi re ct
oryca nbe
ref
e r
redt oa s..s o,ifthewor kingdi rectoryis/home/user,t he
nt her ootdi rectoryc a nbereferr
e dto
as. .
/..(gouponedi re
ctory,the ngoupa notherdirect
or y).Thes ymbol. .c a
nbef r eel
ymi xedinto
paths:thedi re
c toryexamplesbe lowt hec urrentdirec
toryc oul
dha vepa th
examples/../examples/../examples( needles
st osay,s implyusingj ustexamplesi s
recomme nded).

Comma
nds
Commandsar
ejustpr
ogr
amsel
sewhe
reont
hecomputera
ndent
eri
ngt
hei
rna
meont
he
c
omma nd-
li
ner
unsthem.Comma
ndshaveapr
edi
cabl
efor
mat:
command -flags target
Thec omma ndi
sthena meoft heprogr
a mtorun,the(opti
ona l
)flagsmodifyi
tsbeha
viourandthe
ta
rgetiswha tthecomma ndi
st oope ra
teon,oftenthenameofafil e
.Ma nycommandsrequi
re
nei
therflagsnorta
rgetbutUnixt ool
saregener
a l
l
ye xt
remel
yc onfigurabl
eandeve
ns i
mplecomma nds
l
ikedate ha
12
vema nyopti
onalfla
gst ochangetheformatoftheiroutput.

12Someut
il
it
iesa
lsoha
vepa
rodi
es,s
eeddateorslf
ore
xampl
e.
Asme nt i
onedi nFi l
e sanddi rect
ories,therea respecialdir ectoriestoc onta
ine xecutablep r
ograms
andp r
ogr amswi thint hemc anber unb ytypingt hei
rna mea tthec omma nd-l
ine.Inge neralyouwi l
l
notha vepe rmis
siont opl acefil
e sint hesedirectori
esa nde x
pe ri
e ncedUni xusersc re
a t
et heirown,
normally~/bin/,t opl aceprogr a
mst heyus ef r
equently13
.Ifap rogrami snoti nas pecialdir
ectory,
youc annotr unitjus tb ytypingitsna me :thec omput erdoe sn'tk nowwhe retofindite venifthe
programi sinthec urrentdirectory
.Pr ogramswhi char enoti ns pec i
aldi
re c
tori
esc anstil
lber un,but
youha vetoi ncl
udet hepa tht owhe r
ei tcanbef ounda ndt hisc anbea ss impleas./program
(progr
a mi sincurre ntdi r
ectory)toamor ecompl exa bsolutepa tht osome whe rewhe r
es hared
programsa rekept( seefootnote13f o rahintofhowt oa l
leviatet histe
dium forc ommonl yus ed
programs)buty ouc ana l
way suset hec omma nd-l
ine'
sa ut ocompl eti
onfea t
ures,seetab-compl et
ion
below,tor educet hea mountoft y
pingne e
de d.
Onet hingyou'llquickl
ydiscoveristhatt hemous edoe snotmov ethec urs
o rint hetermi nal
.The
ter
mina li
nt e
rfa
cep re
da t
esthepopul ar
ityofmi ceb yde c
adesa ndal
ternati
v eme thodsofe ffici
ent
ly
movinga rounda nde diti
nghavebe ende veloped,keyboardshort-
cut
sbe ingdefinedf ormos tc ommon
operat
ions .Afewoft hesearelis
tedinTa ble3butp robablythemos tusefuli
st het abk e
yt o
completec omma ndna mesandpa t
hsint hefil
e s
ystem,referr
edtoa' tab-completion'.Pressingtab
oncewi l
lc omple
t eapa t
hupt ot hefir
sta mbiguityencounteredandp r
essi
nga ga ingivesal istof
poss
ibl
ec omplet
ions( youc a
nt ypethene x tle
tterors ooftheoney ouwa nta ndp r
esstaba gai
nto
att
emptf urt
hera uto-complet
ion).
Control-a Mov
etobe
ginni
ngofl
i
ne
Control-e Mov
etoe
ndofl
i
ne
Alt-f Mov
efor
war
donewor
d
Alt-b Mov
eba
ckwa
rdsonewor
d
Control-l Cl
ears
cre
en,l
eav
ingc
urr
entl
i
ne
Tab Tr
ytoa
utoma
tic
all
ycompl
etepa
th

Tab
le3:Commonk
eyb
indi
ngsf
ormov
ingar
oundc
ommand-
li
ne.

# Example of tab completion


# For the rest of this tutorial, we will assume the user is called ebi
whoami
ebi
pwd
/home/ebi
ls
Desktop Downloads Pictures Templates Videos
Documents examples.desktop Music Public Ubuntu One
# Change to a different directory don't press enter yet
cd D
# Pressing tab once has no effect since there are three possible options.
# Pressing tab again lists the three options, note thatcd D remains on the
# command-line for further editing.

13Creati
ngthedir
ectorydoesnotmakeits
peci
al.Therei
sav ari
able$PATHwhichi
salistofdir
ect
ori
esi
n
whichthecomputerlooksforp
rogr
amsandthec ommande xport PATH=~/bin:$PATHappendsthenew
dir
ector
ytothisli
st.Thi
sc ommandisof
tenaddedtothefil
e~ /.bashrcwhi
chisalis
tofc ommandstobe
runautomati
cal
lyeveryti
meane wtermi
nali
sope ne
d.

You might also like