This preview shows page 1. Sign up to view the full content.
Unformatted text preview: l window, find "Applic ations " on the menu bar, and c lic k on "Sy s tem Tools " -> "Terminal". A
window s hould pop up with a prom pt that will look s omething lik e this : [ei@iu3~$
In a Unix c ommand line, c ommands have a bas ic format whic h is the name of the program followed by a s pac e, followed by the firs t
argument (if any ), followed by a s pac e, followed by any additional arguments , all s eparated by s pac es . An a rgum e nt is als o k nown
as an option or a parameter. A c ommand will look lik e this :
rga ag] .
The above is c alled a s ynops ys ; it des c ribes c ommand line s y ntax in an abs trac t way . It is not meant to be tak en literally ; eac h
word is a plac eholder for the name of real programs and arguments . [W ords in s quare brac es ] repres ent optional arguments . The
"..." means that optional additional arguments c an follow.
Now we will tak e a look at s ome us eful Unix c ommands . ech o
A s imple program to us e is c alled e cho. This program s imply tak es its arguments and ec hoes them to the terminal, henc e its
name. Try running the following (c opy it ex ac tly ):
eh "a yuha m?
co Cn o er e"
Ins tead of ty ping this manually , mos t terminal programs allow y ou to c opy and pas t the tex t direc tly into the c ommand prompt.
Us ually c ontrol-s hift-v will do the tric k . Don't forget to hit return after entering the c ommand; that tells the terminal that y ou're done
ty ping. Notic e that we put quotes around the argument to the e cho program. Running ins ide the terminal there is a program, c alled
the she ll, whic h reads and interprets the c ommand that y ou ty pe, break ing it up into programs and arguments . Quotes tell the s hell
to interpret "Can y ou hear me?" as one argument rather than 4 and to tak e the "?" c harac ter literally (the s hell us ually tak es "?" to
mean s omething s pec ial). If y ou don't have any s pac es or s pec ial c harac ters in y our argument, y ou don't need quotes . ( | & ; ( ) < >
as well as s pac es and tabs are c ons idered "s pec ial c harac ters ") pw d
Another s imple program is c alled pw d, s hort for "print work ing direc tory ". The work ing direc tory is the c ommand line's notion of
where y ou are in the files y s tem hierarc hy . This is s imilar to the direc tory repres ented by the window y ou have open in the GUI. This
program tak es no arguments , s o y ou jus t run it lik e s o:
You s hould s ee output lik e the following:
This is c alled a pa th. It is a c ompac t des c ription of how to find the direc tory that y ou're c urrently in. Eac h s tep in the travers al is
s eparated by a "/". It s ay s to find this direc tory , s tart at the root of the files y s tem (repres ented by the leading "/"), go into a
s ubdirec tory c alled "home" and then go into a s ubdirec tory named for y our netid. Any path whic h s tarts at the root of the files y s tem
(has a leading "/") is c alled an a bsolute pa th s inc e it is anc hored to the root (lik e the trunk of the tree; every branc h c omes from it).
If y ou lik e, y ou c an c onfirm this des c ription is c orrec t with the GUI. Command history
W ith the terminal in foc us , hit the up arrow a few times . Notic e that the previous c ommands y ou entered appear. You c an us e the
up/down arrow k ey s to navigate through y our c ommand hi...
View Full Document
- Fall '14