IntroductionA Brief OverviewWe communicate with modern computers
by clicking, tapping, sliding, hovering, typing, shaking, and
speaking. Through simple gestures, we are able to command the
computer. Many computeroperating systems such as Windows and OS X
provide a graphical user interface that enables us to open and view
les, play games, turn on music, etc., all by simple movements and
clicks of the mouse. Most operating systems that run on servers,
desktops, and laptops provide another way of commanding your
computer that many people have never even heard of. !t is aptly
called the command line interface "or #$!%, the command line, or
the command prompt.$ike a graphical user interface, the command
line is one way thatthe operating system represents the
computer&s les, directories,and programs "which are also les%
to the user. !n fact, the command line is a te't(based interface
through which one can navigate, create, e'ecute, and act on a
computer&s les and directories with precision.What We'll Cover
in this BookSince the $inu' operating system is the most commonly
used operating system for servers, we will cover its command line
interface in this book. Other operating systems such as Mac OS Xand
)ni' are very similar, so you&ll be able to use everything you
*learn in this book on those operating systems. Other operating
systems, such as Windows, have command prompts, but they di+er in
some signicant ways that make it di,cult to cover theirusage in one
book.How to Use the Command Line)sing the command line is as simple
as opening up Terminal "available on Mac and $inu'% or iTerm
"available on Mac only% on your computer, typing a command and
pressing enter. Most commands will return some kind of output. -o
ahead and open up Terminal and try typing the following command./
echo 01ello World02ou should see something like this./ echo 01ello
World01ello World/There&s nothing spectacular there, but the
above e'ercise illustrates how you can command the computer to do
something and then see its result.What's in it for me?While it may
seem di,cult at rst, being able to use the command line will
empower you as a computer user. Once you&ve3learned the basics
of using the #$!, you&ll be able to simplify and speed up many
tasks that were previously tedious. 2ou can be very precise about
how you want your computer to perform certain tasks, or about which
pieces of information it should display. 4y reading this book and
doing its e'ercises, you&ll gain the following knowledge and
skills. )nderstand commands that tutorials tell you to useo 5s you
learn programming, you will inevitably have to use the command line
to install software, compile or run code, and perform other types
of system administration.o $earning the basics of the command line
will help you understand why you are running the commands, and give
you a general idea of how they work. 6ower over the computero 4eing
able to communicate with your computer or server via command line
gives you immense and precise power over your computer.o With
command line, you can easily monitor your computer and its
resources.o 2ou can take advantage of a lot of powerful tools in
their raw, powerful form.7o 2ou can learn to diagnose issues with
your own softwareand others& software.PreparationsWho should
read this bookThis book is intended to help you on your path to
becoming a skilled programmer. !t covers the basics of command line
usage in a )ni'(like environment, which includes $inu' and Mac OS
X. !t does not include Windows 6owerShell or Windows #ommand 6rompt
usage. !t is assumed that you know the basics of using a computer
and have run a command on the command line before.8nowledge of
programming is not re9uired.ettin! the "ost Out of this BookThere
are a few things you must do to successfully learn the lessons in
this book. :irst, try things out and make what you&ve learned
your own. ;on&t want to mess up your own computer or server<
=o problem. you can easily set up a separate server or virtual
machine to mess around with. See the ne't section for some
suggestions. Second, do the e'ercises. They are there to give you a
real(world understanding of the command line and will help you
remember what you&ve learned. Third, e'plain whatyou&ve
learned to a friend or coworker, or to a rubber duck if that&s
more comfortable.>#erver #etu$!f you don&t want to mess up
your computer&s console while going through the e'amples in
this book, you can set up a serverusing one of many online cloud
services or set up your own virtual machine. The following are some
of the available options.*. Sign up for a service that provides a
full, in(browser development environment, such as =itrous or #loud
? . Once you&ve set up one of these accounts, you can ignore
everything e'cept the terminal or console. We recommend this option
if you&re new to the command line, as it takes the least amount
of e+ort to set up.3. )se @ackspace or ;igital Ocean to set up a
managed server that provides console access. :or this option,
you&ll need a little bit of e'perience with servers.7. Set up a
virtual machine on your computer. 2ou can use Airtualbo' ,AMWare ,
Aagrant , ;ocker , or a combination of these. Setting up a virtual
machine is out of the scope of this book, but a 9uick -oogle search
should be enough to get you going. 2ou should have a lot of
hands(on e'perience with conguring software and in(depth knowledge
of computers before taking this option.The Command Line
InterfaceBWhat is an interface?5ccording to the online Merriam
Webster dictionary, an interface is 0a system that is used for
operating a computer. a system thatcontrols the way information is
shown to a computer user and the way the user is able to work with
the computer.0* 5s this denition e'plains, an interface has two
parts. *% a display of information about what the computer is doing
and 3% a method for telling the computer what to do. The command
line interface is a very basic interface that uses mostly te't for
both the display and input components of the interface. !n a
nutshell, the command line allows for te't(based communication with
a computer. $et&s look at the two parts of the command line
interface. the display and the input.CLI %is$la&The command
line can be the default interface for a computer, but most personal
computers use a program "like Terminal% within the desktop
graphical interface to provide the command line interface.
$et&s dissect the #$!&s language for a moment. To follow
along, log in to your virtual machine or server.4elow is an e'ample
of the prompt on an )buntu $inu' server.ubuntuCchopin.D/The above
prompt follows this
format.EFuserGCFhostnameG.FcurrentHdirectoryG/The FuserG portion
"0ubuntu0% represents the current user that is logged in to the
command line interface. The FhostnameG portion represents the
computer&s name. :ollowing those two pieces is
.FcurrentHdirectoryG. The colon is Iust for separation, and the
FcurrentHdirectoryG displays the path of the directory that you are
in. !f you&ve Iust logged in, it&s probably Iust a tilde
"D%, which represents the home directory. The last piece is / "note
the trailing space%. This whole piece of te't is called the prompt,
or 6S*. !t can be modied to t your needs, but usually displays some
very basic information that shows you the conte't of what
you&re doing. Whenever you log in to a server, or whenever you
open up Terminal on your own computer, you&ll be presented
witha prompt like this one. :or the rest of this book, we&ll
represent the prompt as a simple /.5t the end of the prompt, you
should see a cursor which, in the world of the command line, is
Iust a bo' that blinks on for a second and o+ for a second. The
cursor shows where you are able to input additional te't. The thing
that allows you to input te't is called ST;!= "standard input%.The
last piece of the display portion of the #$! is the output of your
commands. 5s you can see in the image below, when you type a
command, it may have te'tual output.J/ ls Kbin homelibE> opt
sbinusrbootinitrd.imglostLfoundprocsrv vardev initrd.img.oldmedia
rootsys vmlinuMetc lib mnt run tmp vmlinuM.oldWhen the output has
printed to the screen and the command or program e'its, the prompt
is displayed again below the output. To review, the components of
the #$! display are the prompt, the cursor, the input "te't you
have typed in%, and the output of your commands and programs.CLI
In$utThe second component of this te'tual interface is the input.
4y typing te't into the command line interface, you are creating
input for the #$! to interpret and act on. )sing commands such as
echo or ls, you can command the computer to do your bidding.
$et&s try a command. Try typingecho 01ello World0 into the
console./ echo 01ello World0The echo command is very simple, but it
can also be very useful. 5ll it does is send te't to the #$!&s
output. 5nother useful command is the pwdcommand. !f you want to
know where you arein your computer&s le system, you can type
pwd and press enter to e'ecute it. 2ou should get something like
the following as output from that command.N/ pwdKhomeKubuntuThe
commands above are simple, and don&t actually make any changes
to your command line environment, the computer, or itsles (( they
only display some output. 4ut other commands such as rm, cp, and
source can directly a+ect the les on your computer or can change
your command line environment.'he Anatom& of a Command#ommands
come in all shapes and siMes, but they have many features in
common. When you type a command into a terminal, it will always
take the following format.FcommandG Farguments...G5 command can be
the path to a le "e.g. KpathKtoKle%, or it can be a command that
your terminal is already aware of "e.g. echo%. Thesecond portion of
the command usually consists of what are called 0arguments0.
5rguments are strings that are passed to theprogram that you are
e'ecuting. Stated more simply, these are pieces of information that
you are providing to your command.To better understand how this
works, we can compare the command line and its commands to a
well(trained army. !n this army, each soldier has a very specic
duty, and is trained to do itwith perfection. Some duties, like
cleaning the dishes, don&t take any e'tra information for them
to be accomplished successfully. ?Other duties re9uire, or at least
benet from, e'tra information. !fyou are the general and you tell a
soldier to go on patrol, he maybe able to go out and patrol
somewhere, but it may or may not be where you need him most.
1e&ll probably Iust go to his usual patrolling area and start
there.#ommand line commands are basically the same. !f you type a
command by itself, it will sometimes e'ecute Iust ne, using default
information to do its Iob. Other times, however, you reallyneed to
give the command more information so that it can know e'actly how
to perform its duty. Take, for e'ample, the tar command. !f you
open the command line prompt, typetar, and press enter, it
won&t do much. !n fact, all it does is ask you for more
information. 02ou want me to patrol< Where should ! patrol opt
sbinusrbootinitrd.imglostLfoundprocsrv vardev initrd.img.oldmedia
rootsys vmlinuMetc lib mnt run tmp vmlinuM.oldWithout any
arguments, ls Iust prints out a list of the les and directories in
the current directory. !t doesn&t tell you much about those les
and directories, though. !f you add a couple of arguments, you can
get the lscommand to give up more information about each item in
the directory./ ls (lahtotal N>8drw'r('r('33 root root >.Q8
May *> *J.7* .drw'r('r('33 root root >.Q8 May *> *J.7*
..drw'r('r(' 3 root root >.Q8 May *3 37.3Q bindrw'r('r(' 7 root
root >.Q8 May *3 37.3Q bootdrw'r('r('*7 root root 7.?8 May *>
*J.7* dev*Jdrw'r('r('?E root root >.Q8 Yun 33 *J.*B
etcdrw'r('r(' 7 root root >.Q8 May *3 37.*? homelrw'rw'rw' *
root root 77 May *3 37.3Q initrd.img (Z
bootKinitrd.img(7.*7.Q(B3(genericlrw'rw'rw' * root root 77 Mar 3B
**.B* initrd.img.old (Z
bootKinitrd.img(7.*7.Q(>N(genericdrw'r('r('3* root root >.Q8
May *7 *?.Q7 libdrw'r('r(' 3 root root >.Q8 Mar 3B **.BQ
libE>drw'(((((( 3 root root*E8 Mar 3B **.B7 lostLfounddrw'r('r('
3 root root >.Q8 Mar 3B **.BQ mediadrw'r('r(' 3 root root
>.Q8 5pr *Q3Q*> mntdrw'r('r(' 3 root root >.Q8 Mar 3B
**.BQ optdr('r('r(' *3J root rootQ May *> *J.7Q procdrw'(((((( 7
root root >.Q8 May *7 *?.QQ rootdrw'r('r('*N root rootJQQ Yul*
*>.*3 rundrw'r('r(' 3 root root >.Q8 May *3 37.3Q
sbindrw'r('r(' > ubuntu ubuntu >.Q8 Yun 33 *J.QE
srvdr('r('r('*7 root rootQ May *> *J.7Q sysdrw'rw'rwt > root
root >.Q8 Yul* *>.>Q tmpdrw'r('r('*Q root root >.Q8 Mar
3B **.BQ usrdrw'r('r('*3 root root >.Q8 Mar 3B **.B3
varlrw'rw'rw' * root root 7Q May *3 37.3Q vmlinuM (Z
bootKvmlinuM(7.*7.Q(B3(genericlrw'rw'rw' * root root 7Q Mar 3B
**.B* vmlinuM.old (Z bootKvmlinuM(7.*7.Q(>N(genericWe&ll go
into detail of what everything means in later chapters, but for
now, you can see that adding the arguments (l, (a, and (h "grouped
into one argument above%, *Nadds a lot more information and formats
the items into a more easy(to(read list.?. The command line o+ers a
bunch of commands to work withles and directories. This e'ercise
will show the basic usage of the following.touch, mkdir, mv, cp,
and rm.:irst, let&s make sure we&re in your home directory
"recall that D stands for your home directory%./ cd D/
pwdKhomeKubuntu=ow, let&s create a practice directory to mess
around with./ P Make a directory called 0practice0/ mkdir practice/
lspractice2ou can see that now there&s a directory named
0practice0 inyour home directory. $et&s change our current
directory to the 0practice0 directory that we Iust created./ cd
practice*?=ow, in this directory we can create new les, move or
rename them, copy them, and remove them. 5fter that,
we&llremove the whole 0practice0 directory to clean up./ P
#reate an empty le and verify that it got created/ touch
e'ample.t't/ lse'ample.t'tThe touch command created the empty le
0e'ample.t't0 in the current directory. 2ou can move or rename a le
with the mv command./ P @ename e'ample.t't to e'ample*.t't/ mv
e'ample.t't e'ample*.t't/ lse'ample*.t't/ P Make another directory/
mkdir tmp/ P Move e'ample*.t't to the new 0tmp0 directory/ mv
e'ample*.t't tmpK/ ls tmpKe'ample*.t't/ lstmp/ P Move it back and
rename it/ mv tmpKe'ample*.t't e'ample3.t't/ ls3Qe'ample3.t't
tmp2ou can see from the above e'amples that moving or renaming a le
is basically the same thing on the command line, and follows this
pattern./ mv FsourceG FdestinationG=ow, let&s remove the
e'ample le and then the whole practice folder./ rm e'ample3.t't/
lstmpTo remove a folder and all its contents, you need to specify
the (r"recursive% option./ cd ../ lspractice/ rm (r practice/ lsThe
practice folder "and all its contents% are now gone.Warning. using
the rm command is dangerous and permanent. ;o not issue this
command until you know for 3*certain you are deleting the right le.
)sing the rm (r command is even more dangerous, as it will delete
recursively.*Q. One of the most common tasks when using the command
line interface is reading the contents of a le. Thise'ercise will
go over some common commands for doing so. cat, more, less, head,
and tail.To print out all the contents of a le, use cat./ cat
le.t't5ll the content of le.t't printed out here.To print out the
rst few lines of a le, use head./ head
KetcKmime.typesPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPM!MR
media types and the e'tensions that represent them.PPThe format of
this le is a media type on the left and Mero or morePlename
e'tensions on the right.6rograms using this le will mapPles ending
with those e'tensions to the associated type.PPThis le is part of
the 0mime(support0 package.6lease report a bug usingPthe
0reportbug0 command of the 0reportbug0 package if you would like
new33To print out the last few lines of a le, use tail./ tail
KetcKmime.typestail
KetcKmime.typesvideoK'(ms(wm'wm'videoK'(ms(wv'wv'videoK'(msvideo
avivideoK'(sgi(movie movievideoK'(matroskampv
mkv'(conferenceK'(cooltalk ice'(epocK'(sis'(app
sis''(worldK'(vrmlTo print out the contents of a le, but only ll
one screen&s worth at a time, use more./ more KetcKmime.typesP
The rst page of KetcKmime.types will show up here, and you can use
theP down arrow to go to the ne't line, or the space bar to go to
the ne'tP page.)se less when you need to navigate backward and
forward ina le./ less KetcKmime.types37The less command allows you
to go forward one line with the down arrow, backward one line with
the up arrow, and backward and forward a page with the page up and
page down keys. 2ou can also use the space bar in the same way you
can with the more command.=ote. to e'it more or less, type the 9
key.**. 2ou can get more information about what a command does, how
it works, and which Sags you can use by referencing the manual for
that command. To read the manual pages "typically called manpages%
for a command, use the man command.*3. / man touch*7. TO)#1"*%)ser
#ommands TO)#1"*%*>.*B.*E.*J. =5MR*N.touch ( change le
timestamps*?.3Q. S2=O6S!S3*.touch FO6T!O=G... :!$R...33.37.
;RS#@!6T!O=3>.)pdatethe access and modication times of each :!$R
to the3B.current time.3>3E. ...The manual pages will sometimes
have the available Sags and the possible orders they can be used in
in the 0S2=O6S!S0 section. !n the case of the touch command, the
Sags can be used in any order Iust after the touch command itself,
and the le is the last argument. The possible options are described
in the 0;RS#@!6T!O=0 section.2ou may have noticed that the man
command uses less to display the content of the manpages, so you
can use the up(and down(arrow keys to navigate the contents of the
manual.To e'it man, you can type the 9 key.Files, Directories, and
Executables'he Core of the Command Line!n a desktop environment,
like that of OS X, you have windows, menu bars, and the desktop to
give conte't to what you are doing. !n the command line, however,
the conte't is solely the le system. !n fact, les and directories
are what make up the command line. 5lmost everything you do at the
prompt will deal 3Bwith les. Rvery time you type a command, you are
telling the computer to e'ecute a le.=ot only does the le system
provide conte't for you when you&re trying to work on or get
information about les and directories, it also provides conte't for
the commands you run. :or e'ample, you can use the lscommand to
list the les in a directory. When you run the command by itself, it
uses your current directory as conte't, and lists the les that are
in the directory you are in.Linu)*Uni) +ile #&stem
Le!end$et&s look for a moment at some of the symbols that will
help us navigate the command line. K ( The root directory or a
separator when listing directories . ( The current directory "also
.K% or the same level .. ( The directory one level up "also ..K%
..K.. ( Two levels up D ( 2our 0home0 directory, or the directory
you are placed in when you log in. [ ( The 0splat0 or 0glob0
operator. This is the wildcard of the command line and represents
0any characters.03EThe above symbols can be combined with directory
and le names to represent their locations. The path KhomeKubuntu
can be dissected as follows.root directory L 0home0 directory L
directory separator L 0ubuntu0 "user%directoryWhile it may not make
sense to do so, somewhat 0nonsensical0 combinations can represent
valid paths. The following path is thesame
asKhomeKubuntu.KhomeKubuntuK..K..K.KhomeKubuntuK$et&s break the
above path into its parts. KhomeKubuntuK ( The ubuntu directory
within the home directory within the root "K% directory. ..K..K (
)p two directories "which takes us back to the root directory%. .K
( The same directory "which is still K%. homeKubuntuK ( 4ack down
into the home directory, then the ubuntu directory.=ote that
there&s a dramatic di+erence between a path that starts with a
leading slash vs one that doesn&t. :or e'ample.3J KhomeKubuntu
This path species a le called 0ubuntu0 that lives under your root
directory, then home directory. homeKubuntu This path species a
completely di+erent le. This path means there&s a le called
0ubuntu0 that lives in a directory called 0home0, which is itself
in the current directory.The leading slash makes all the di+erence.
Make sure to pay careful attention to that whenever you&re
looking at paths.,avi!atin!=avigating your computer&s le system
is pretty easy with the help of the :ile System $egend above, and a
few simple commands. cd ( change directory ls ( list les pwd (
display the current working directory$et&s get a feel for
navigating the command line interface by opening up Terminal or
logging in to your managed server or virtual machine and treading
water for a bit. 5fter logging in, type the following commands and
note what happens after each step.P #hange directory "with no
arguments%3N/ cd/ pwdKhomeKubuntuP #hange to root directory/ cd K/
pwdKP #hange directory "with no arguments again%/ cd/
pwdKhomeKubuntuP -o up one directory/ cd ..K/ pwdKhomeP Show les
and directories "with no arguments, it uses current directory%/
lsubuntuP =avigate into 0ubuntu0 directory/ cd ubuntu/
pwdKhomeKubuntu3?P #hange to D "home% directory/ cd D/
pwdKhomeKubuntuP Show les and directories in root directory/ ls
KbinbootdevetchomeliblibE>mediamntoptprocrootrootfsrunsbinselinu'srvsystmpusrvarP
Show les that match a certain patternP using the splat operator
"asterisk%/ ls K[otboot root;id you notice that typing cd by itself
takes you to your 0home0 directory< Which command"s% made you
0descend0 into a directory< Which command"s% made you go up a
directory< What was the di+erence in the output of ls vs. ls
K< What do you think the output of ls .K would be if you rst ran
cd K/ ls (d .[. .bashHhistory.bashHprole.cache
.gem.npm.viminfo...bashHlogout .bashrc.cong.local.prole.ssh3. $ist
the hidden les in the parent directory. Then list the lesin the
parent directory&s parent directory.#olution2ou can list a
parent directory&s les using the following command./ ls
..ubuntuWhat happens if you run that command from the root
directory opt sbinusrbootinitrd.imglostLfoundprocsrv vardev
initrd.img.oldmedia rootsys vmlinuMetc lib mnt run tmp
vmlinuM.old5s you can see, since the root directory doesn&t
have a parent directory, it Iust prints out the les in the root
directory itself.7BTo list the les of the parent&s parent
directory, Iust add a slash and an e'tra .../ cd/ ls ..K..bin
homelibE> opt sbinusrbootinitrd.imglostLfoundprocsrv vardev
initrd.img.oldmedia rootsys vmlinuMetc lib mnt run tmp
vmlinuM.old7. What&s the di+erence between abcK and
Kabclibe'eclocalsbinsharesrctmp)se the (lah set of Sags as
arguments to the ls command to get more detailed information about
les and directories./ cd K/ ls (lahtotal **38dr('r('r(' 3> root
root >.Q8 Mar *E 3Q.BE .dr('r('r(' 3> root root >.Q8 Mar
*E 3Q.BE ..(rw(r((r((* root rootQ Mar *E 3Q.BE .autofsckdr('r('r('3
root root >.Q8 Oct*3Q*> bindr('r('r('7 root root >.Q8
Oct*3Q*> bootdrw'r('r(' *E root root 3.N8 Yun7 3*.>N
devdrw'r('r(' JE root root >.Q8 Yun7 3*.>N etcdrw'r('r('7
root root >.Q8 Sep 3?3Q*> homedr('r('r('J root root >.Q8
Mar 3B3Q*> libdr('r('r(' *Q root root*38 Oct*3Q*>
libE>drw'r('r('3 root root >.Q8 Mar 3B3Q*>
localdrw'((((((3 root root*E8 Mar 3B3Q*> lostLfounddrw'r('r('3
root root >.Q8 YanE3Q*3 mediadrw'r('r('3 root root >.Q8
YanE3Q*3 mntdrw'r('r('7 root root >.Q8 Mar 3B3Q*>
optdr('r('r(' JB root rootQ Mar *E 3Q.BE procdr('r('(((7 root root
>.Q8 Yun7 3*.>N rootdrw'r('r('> root root >.Q8 Sep
3?3Q*> rundr('r('r('3 root root*38 Oct*3Q*> sbindrw'r('r('3
root root >.Q8 YanE3Q*3 selinu'>Qdrw'r('r('3 root root
>.Q8 YanE3Q*3 srvdr('r('r(' *7 root rootQ Mar *E 3Q.BE
sysdrw'rw'rwt7 root root >.Q8 Yun *Q Q7.7> tmpdrw'r('r(' *7
root root >.Q8 Mar 3B3Q*> usrdrw'r('r(' *? root root >.Q8
Mar 3B3Q*> varN. !n this e'ercise we&re going to play with
e'ecutables. We&ll nd the location of so(called 0default
e'ecutables0 by using the which command, then e'ecute a le using
its absolute path.To gure out a default e'ecutable&s location,
you can use the whichcommand./ which touchKbinKtouch=ow we can
e'ecute the touch command using it&s full path or it&s
name./ cd/ touch test/ lstest/ KbinKtouch test3/ lstest
test3>*We can do the same thing now with the rm command.WarningX
The 0rm0 command is e'tremely dangerous. There is no easy, or even
moderately di,cult, way to restore what you delete with the 0rm0
commandX/ cd/ rm test/ lstest3/ which rmKbinKrm/ KbinKrm test3/
ls/The Environment(nvironment -ariables!n the last chapter, we
talked about how your 0current directory0 provides conte't for
commands you run. 5nother way of providing conte't is through
something called environment variables. !n programming, variables
are used to store data and to be able to reference and retrieve
that data at a later point using a name. !n the command cd /1OMR,
the /1OMR part is a reference to the 1OMR variable, and is replaced
by the path to your home directory when the command is run. !n
other words, >3running cd /1OMR is the same as running cd
KhomeKubuntu, assuming your home directory is KhomeKubuntu.When you
log in to the command line, a variety of environment variables are
automatically set. 2ou can see e'actly what variables have been
set, along with their values, by running env at the command line.
Type env, hit enter, and nd the value for 1OMR. !t should say
something like KhomeKubuntu, where ubuntu will be replaced by your
username. !f you&re doing this ona Mac, the value will probably
be something like K)sersKbob. This is the path to your home
directory.How to Chan!e &our Command Line (nvironmentWhile
there are several environment variables that are set for you
automatically, you can also set your own or modify e'isting
variables. 2ou can do this on the Sy, so that your changes only
a+ect the current command or the current session, or you can make
the changes more permanent so that they stick between
sessions.=ote. The term 0session0 refers to the state of being
logged in to a computer&s command line interface. When you log
in, you start a new session, in which your commands will be
recorded and other conte'tual information will be maintained. When
you close Terminal or type 0e'it0, your session is closed and that
conte't and data is lost.#ettin! (nvironment -ariables on the
+l&>7There are two ways to set an environment variable on
the Sy.*. Set the variable on its own line, then use it anywhere./
SOMRT1!=-\&some value&/ echo /SOMRT1!=-some value3. Set the
variable before a command, on the same line./ SOMRT1!=-\&a
value& env...SOMRT1!=-\a value...=ote. 2ou cannot "very easily%
use a value on the same line that you set it. That&s because
variables are evaluated before the setting occurs./
SOMRT1!=-\&something else& echo /SOMRT1!=-P no output;id
you notice that when you set a variable you don&t prepend the
dollar sign, but when you reference it, you do< 5lso note that
there should be no spaces between the variable and the e9ual sign
or the e9ual sign and the value. $astly, it&s usually best to
use 9uotations around the value that you are assigning to the
>>variable, but you don&t have to when the value
doesn&t have any special characters.$et&s try changing our
current session&s environment. Maybe you&d like to simplify
your prompt. To change your prompt, adIustthe 6S* variable to
whatever you&d like it to be./ 6S*\0"testprompt%Z
0"testprompt%Z5s you can see, the prompt is now "testprompt%Z, and
every time a command nishes, it will show up again. !f you want a
more complicated prompt, try the following./
6S*\0]n]F]eFQO7Jm]GF]hG
]eFQO7Bm]G]d]eFQm]G]n]F]eFQO7*m]G]u]F]eFQO7>m]G in
]F]eF*O77m]G]w]F]eFm]G]F]eFQO7*m]G]n]F]Q77F7Bm]G/]F]Q77FQQm]G
0FchopinG Wed 5pr QNubuntu in D/The new prompt is multi(line and
has color(coding. !f you want to revert to your old prompt, Iust
close your session and start a newone. Since we made the changes to
the environment variable 6S* on the Sy, they won&t be used in
future sessions."akin! "ore .ermanent Chan!es>B!t is possible to
make more permanent changes to the command line environment. When
you start a command line session by opening a new Terminal window,
one or more environment les are e'ecuted. These les can be used to
modify or create environment variables. They are usually located in
your home directory and include the following les.
.bashrc,.bashHprole, .bashHlogin, .login, .prole. 4ecause they
start with a ., they are considered to be 0hidden0 les, and using
the ls command alone won&t show them. Type ls (a D to see them
listed along with other les in your home directory. @emember, the
ls is the command, and the (a and Dare arguments to the ls command.
The (a Sag tells the ls command to include les that start with . in
its output, while the D is the directory that lsshould inspect
"recall that D means your 0home0 directory%./ ls (a
D..cache.sudoHasHadminHsuccessful..
.mys9lHhistory.vbo'Hversion.bashHhistorypostinstall.sh.veeweeHversion.bashHlogout
.prole.vim.bashrc.ssh.viminfoThe rules behind which environment le
is read for a new sessionare complicated and depend on how the
session is created. :or our purposes, using .bashrc should be
su,cient. !f your edits aren&t working, try one of the other
les.$og in to your console and type the following command.>E/
cat DK.bashrc2ou should see some lines that start with e'port. The
e'port command basically means 0make this variable available
globally,0 and variable assignment that starts with e'port in your
.bashrc will be included in your environment when you log in. =ote
that if an environment variable has beene'ported once, you
don&t need to continually put e'port before it when you set its
value.!f you&re ready to customiMe your prompt a bit more
permanently,add your custom prompt to the bottom of your .bashrc
le.6S*\0Fyour custom prompt goes hereG 0The e'port isn&t needed
because the variable is already available globally. )se the
following pieces along with any custom te't to make your prompt./h
1ostname/u )ser name/w #urrent directory/W 4asename of current
directory/d #urrent date>J/n =ewline;id you notice that Iust
editing and saving your .bashrc le didn&t do anything< The
le is only evaluated, or run, when you rst login. !f you want to
re(run a particular environment le like .bashrc or .bashHprole, use
thesource command./ source DK.bashrc;o revert back to your old
prompt, edit the same le and removeyour 6S*setting. Then run source
on that le.Fmy custom promptG/ source DK.bashrc/Usin! (nvironment
-ariables$et&s look for a moment at the di+erent ways we can
use environment variables.01 As .arts of Commands:irst, variables
can be used as arguments to commands. Take a look at the following
e'ample./ MRSS5-R\&1ello, worldX&/ echo /MRSS5-R1ello,
worldX>NThis is a very simple e'ample, but you can see that the
/MRSS5-R variable is used as the rst "and only% argument to the
echo command. 2ou can actually use variables as commands as well./
MRSS5-R\&1ello, worldX&/ #OMM5=;\0echo0/ /#OMM5=;
/MRSS5-R1ello, worldX21 Inter$olated in #trin!sAariables can also
be interpolated, or included, in other strings. Take the following
e'ample./ MRSS5-R*\0This is message *.0/ MRSS5-R3\0This is message
3.0/ MRSS5-R\0/MRSS5-R* /MRSS5-R30/ echo /MRSS5-RThis is message *.
This is message 3.To have a variable get interpolated, you have to
use the double 9uotation mark "0%, not the single 9uotes "&%.
Try the following e'ample in your command line./ MRSS5-R*\0This is
message *.0/ MRSS5-R3\0This is message 3.0/ MRSS5-R\&/MRSS5-R*
/MRSS5-R3&>?/ echo /MRSS5-R/MRSS5-R* /MRSS5-R331 Behind the
#cenesRnvironment variables can be used by commands "programs%
behind the scenes. !n other words, you can set a variable, then run
a command without passing the variable as an e'plicit argument to
that command, and the command could use that variable. The 6W;
variable is automatically used by any commandthat tries to get the
user&s current directory. The 1OMR variable is automatically
used by cd when you don&t pass any arguments to it. !f you make
up a custom variable "like 6!\7.*>%, only programs that know
about it will be able to use it without e'plicitly using it as an
argument.!f you want to temporarily change a variable before it
gets used in a command behind the scenes, you can set the variable
immediately preceding the command on the same line.P Set home to
root directory and change to home./ 1OMR\K cd/ pwdKP #hange to home
directory./ cd/ pwdBQKhomeKubuntu=ote how that the second cd takes
you to your original home directory, whereas the rst cd takes you
to the root directory because that&s what you set 1OMR to.4.A'H
and ()ecutablesOne of the most important environment variables
you&ll work with on the command line is 65T1. !n the last
chapter, we discussed how commands are really Iust les, but we
didn&t talk about how the command line knew which le to e'ecute
for commands like cd or echo or other built(in or installed
programs. The 65T1 variable provides the additional conte't that
the command line needs to gure out which particular le to e'ecute.
$et&s look at a 65T1 variable&s value./ echo
/65T1KusrKlocalKsbin.KusrKlocalKbin.KusrKsbin.KusrKbin.Ksbin.Kbin.KusrKgames!f
you e'amine the output of the echo /65T1 command above, you&ll
see that it is a bunch of paths connected by colons. 2ou may have
noticed that most of the paths end in Kbin. This is because bin is
short for 0binary0, and bin is a standard directory name for
e'ecutable les, or programs.$et&s look at what resides in one
of the directories listed in the 65T1 variable.B*/ ls KusrKbinF
mys9lanalyMe3to7mys9lbinlog3to7(3.Jmys9lbuga3p mys9lcheckaclocal
mys9lHclientHtestaclocal(*.**mys9lHconvertHtableHformat...mys9l
Mdumpmys9laccess Msoelimmys9ladmin;epending on your computer,
di+erent types of les may have di+erent colors. On many computers,
for e'ample, e'ecutables will probably be colored green. !f you
look at the les located in your home directory, however, they are
probably white and blue,which tells us that they are not
e'ecutable.One of the items in the KusrKbin directory is man. !f !
type man on thecommand line and hit enter, it will e'ecute that le.
1ow can ! besure that it will e'ecute that le, and not some other
le that happens to be named manon my server4 Yul *> *B.3>
.drw'r('r('J acmeairpublic 37N4 Yul *> *B.37 ..(rw(r((r((*
acmeairvipQ4 Yul *> *B.37 co+eeB?drw'rw'rw'3 acmeairacmeair EN4
Yul *> *B.37 custodianHcloset(rw(r((r((* acmeairvip34 Yul *>
*B.3> donut(rw'r((r((* acmeairvip *-4 Yul *> *B.3>
internetHaccess5s mentioned above, permissions have three access
types. read "r%, write "w%, and e'ecute "'%. 4oth les and
directories have access types assigned to them, and each can be
assigned a user and a group. The 0other0 level of ownership always
includes everyone else implicitly. !t looks like this. 5 le or
directory has.o an owner L owner&s rw' access levelso a group L
group&s rw' access levelso other&s rw' access levels!n the
vipHlounge e'ample above, you can see to the left of each le a
string of characters that starts with a dash "which can also be a d
to indicate a directory%, then ? more characters consisting of r
"0read0%, w "0write and delete0%, ' "0e'ecute0%, and ( "0permission
not granted0%. Where a letter e'ists, that access type is granted,
and where the dash e'ists, that permission is not granted.5fter the
string of d, rs, ws, 's, and dashes in the rst item in the list,
you can see acmeair vip. These two strings represent the user and
group assigned to the le or directory. !n this case, the nameof the
user is 0acmeair0 and the name of the group is 0vip0.EQThe
following chart shows what each part of the permissions represents.
Rach of the rst *Q characters can be replaced with adash to show
that that access level is not granted or, in the case of the d,
that the obIect in 9uestion is not a directory. $et&s take
alook at a diagram to make this a bit easier to understand.P
L(((((((( ;irectory or notP UL((((((( )ser @ead, Write, R'ecuteP UU
L((((((( -roup @ead, Write, R'ecuteP UU U L((((( Other @ead, Write,
R'ecuteP UU U U L((( The name of the userP UU U U U L((( The name
of the groupP UU U U U UP dUrw'Urw'Urw' user group=ow that we
understand how the permissions are laid out, we can interpret the
output of the ls (lah command we ran previously. !f you look at the
rst item displayed, the . directory "also vipHlounge%, we can
gather the following. d. !t is a directory. rw'. !ts user has read,
write, and e'ecute access. r('. !ts group has read and e'ecute
access. r('. Other also has read and e'ecute access. The user named
0acmeair0 has been assigned to it.E* The group called 0vip0 has
been assigned to it.!n practice, this means the directory&s
default permissions allow for les to be read and e'ecuted by any
user, and written to by the user 0acmeair.0!n this hypothetical le
system, the vip group would have multipleusers associated with it,
such as acmeair, bob, dave, etc. $et&s pretend that the
following users e'ist and belong to the groups listed beneath them
"we&ll be talking about groups more in a later section%./
groups bobbob vip/ groups acmeairacmeair vip/ groups Ie+Ie+
acmeair!n this scenario, anyone that belongs to the vip group would
have group access to anything that is assigned the vip group. The
user bob, based on his groups as listed above, would have the
ability to enter the vipHloungedirectory and partake of "i.e. read%
itsdonut, co+ee, and internet access content. The bob user,
however, wouldn&t have access to enter thecustodianHcloset
content or use its contents, but Ie+ and acmeair would.5n important
thing to note from the above e'ample is that the permissions are
not bestowed upon the user or groups. @ather, E3the les and
directories are assigned groups and users, with particular
permission levels for those. !t&s kind of like a reservation at
a restaurant table. There&s nothing about a person that
inherently gives them permission to dine at a restaurant at
aparticular table and at a particular time. !t&s because the
restaurant has labeled, or set apart, that table for that time that
the person is able to dine there. So it is with the le system.
There&s nothing inherently special about any group or user
"e'cept the root user%. 5 user&s privileges are dened by the
les and directories themselves.#ettin! .ermissionsThere are a few
ways of setting the permissions on a le or directory. Thechmod
command will be your friend here. To add write permissions to a le,
for e'ample, you can do something like this./ chmod Lw
sample.t'tThe Lw means 0add write access.0 !f you want to get more
granular in how you set permissions on a le or directory, you can
pre' the permission withu, g, o, or a, which stand for 0user
"owner%0, 0group0, 0other0, and 0all0, respectively./ ls (lah
test.t't(rw'r((r((* bobsta+*-4 Yul *> *B.3> test.t'tE7/ P
@emove write access for user/ chmod u(w test.t't/ ls (lah
test.t't(r('r((r((* bobsta+*-4 Yul *> *B.3> test.t't/ P 5dd
e'ecute access for group/ chmod gL' test.t't/ ls (lah
test.t't(r(wr'(r((* bobsta+*-4 Yul *> *B.3> test.t'tWhat if
you want to set access level permissions for the user, group, and
other all at once< 2ou can do so with 7 numbers, eachfrom Q to
J. Why Q(J< There are 37 "which is 3 [ 3 [3, or N% permission
levels. When you count from Q to J, there are actuallyeight
numbers. =ote that it&s really common in computer languages to
count starting from Mero rather than *. !n this octal system, read,
write, and e'ecute permissions each add *, 3, and >
respectively, resulting in non(ambiguous designations of
permissions. !n short, here are the di+erent combinations of
permissions based on the octal mask.The following table shows what
access level each number represents.,umber .ermissionQ =o
permission granted.* #an e'ecute.E>,umber .ermission3 #an
write.7 #an write and e'ecute "3 L * \ 7%.> #an read.B #an read
and e'ecute "> L* \ B%.E #an read and write "> L 3 \ E%.J #an
read and write and e'ecute "> L 3 L * \ J%.!f you combine the
permissions from the table aboveTone each for owner, group, and
otherTyou can dene the whole set of permissions for a le or
directory./ chmod JJJ test.sh/ ls (l test.sh(rw'rw'rw'* bob admin
Q4 Yul *B *B.3> test.sh/ chmod QQQ test.sh/ ls (l
test.sh((((((((((* bob admin Q4 Yul *B *B.3> test.shEB/ chmod
JB> test.sh/ ls (l test.sh(rw'r('r((* bob admin Q4 Yul *B
*B.3> test.sh=ote. in order to change the permissions of a le or
directory, you much be its owner, be root, or use sudo. See the
@oot )ser and Sudo section below .Users and rou$sWe know that a
user and a group are assigned to all les and directories in $inu'
and )ni' systems, and it is pretty obvious that if your user is
assigned to a le, you will have the ability to read, write, or
e'ecute the le according to the access types granted. 4ut how do
groups work< )sers can belong to multiple groups, and groups can
have multiple users. !f a user belongs to a group, it will have the
access types granted to the assigned group of any le or directory.
So, in our ls (lah e'ample above, the le named 0donut.t't0 can be
read "or consumedX% by any user inthe 0vip0 group.To determine if
your user is part of a certain group, use the groupscommand./
groupsubuntu adm dialout cdrom Soppy sudo audio dip video plugdev
netdevEE!n the above e'ample, the 0ubuntu0 user is part of several
groups, the rst being a group of the same name as the user.
0ubuntu0.5oot User and #udo!n )ni' and $inu' systems, there is a
special user called 0root.0 The root user is the super userTit can
read, write, and delete any le. !f the 0acmeair0 user is like an
airline company, then theroot user is basically a god. 4ecause the
root user has so much power, it is a common recommendation to not
log in as root, and to only run commands with root when necessary.
!f you are logged in as a non(root user and know the root
user&s password, you can switch to the root user account at any
time with the following command./ su (6assword.!f you put in the
above command, you will be re9uired to put in the root user&s
password. =ote. you may not have root access if you are using a
managed server environment.5lthough the root user can read, write,
and delete "almost% any le, it cannot e'ecute Iust any le. 5s
mentioned in the chapter 0:iles, :olders, and R'ecutables0, a le
can only be e'ecuted if it has the e'ecute permission granted. !n
the case of the root user, it doesn&t matter who the permission
is granted toO as long as it is granted to the user, the group, or
other, root can e'ecute it.EJ#udoWhile you will be able to log in
as root directly in some scenarios,it is more common to use the
sudo command to perform actions that re9uire root privileges. 2ou
can think of it as borrowing the god(like powers of the root user
for a moment. The sudo command allows you to 0do0 something as a
0super user.0 When you use this command, you will usually be
re9uired to input a passwordO but instead of the root user&s
password, you&ll be putting in your own password. The following
is an e'ample of a command that re9uires root privileges, but that
canbe run using sudo "don&t run this unless you want your
computer to rebootX%.sudo reboot4ut why use sudo instead of Iust
logging in as root< There are several reasons for doing this,
including the following. The server administrator wants you to have
root access for some commands andKor directories, but not for
everything. !n this case the administrator will set up sudo to have
restrictions or whitelisted commands. @unning commands while logged
in as root can be dangerous. )sing a non(root user makes it obvious
when youare running a command that re9uires root privileges because
you have to pre' your command withsudo.EN The sudo command provides
a detailed audit trail so that system administrators can track what
commands individualsused on system les. Sudo uses a ticketing
system where you put in your password once, then you don&t have
to until you haven&t run any sudo commands for ve minutes or
longer. This adds security to your command line session, preventing
others from gaining root access if you leave your Terminal open on
accident.#ummar&:ile system permissions are complicated, and
are probably one ofthe biggest sources of headaches for command
line beginners. 4ut having a basic understanding of how permissions
work will get you a long way. @emember. 6ermissions are assigned to
les and directoriesTnot users and groups. 5ccess levels are
determined by the rw' "read, write, e'ecute% permissions for the
owner, group, and other. 5 le must have the ' "e'ecute% permission
to e'ecute that le directly. To change the permissions of a le or
directory, you either must be logged in as that le&s owner or
the root user, or you must use the sudocommand.E?With an
understanding of the above, you&ll be able to resolve many
issues that you will surely run into while programming.()ercises*.
Which user and group are assigned to the Ketc folder on your
computerServer version. B.E.*7 Source distribution#opyright "c%
3QQQ, 3Q*7, Oracle andKor its a,liates. 5ll rights reserved.Oracle
is a registered trademark of Oracle #orporation andKor itsa,liates.
Other names may be trademarks of their respectiveowners.Type
&helpO& or &]h& for help. Type &]c& to
clear the current input statement.mys9lZThe prompt is now simply
mys9lZ, and commands such as ls, echo, and cdno longer work.
!nstead, only SW$ and other MySW$ commands are available for use.
The mys9l program essentially hiIacks the command line session
until you e'it out using the W)!T command.JE#onnecting to a MySW$
server with the mys9l command allows you to 9uery databases and
otherwise manage the database server. Yust like the regular command
line interface, there is input "ST;!=% and output "ST;O)T%. !f you
type S1OW ;5T545SRSO, it will print to the screen a list of
databases on the server. !f you type SR$R#T * L *O, it will output
a table with the result of * L *.To get back to the command line
interface, type &W)!T& and hit enter.5ead6(val6.rint6Loo$
75(.L86rograms that follow the pattern of reading user input,
evaluating the input, printing results of the input to the screen,
and then allowing for more input, are called 0@R6$s0, or
0@ead(Rval(6rint($oop0 programs or interfaces. Themys9l command
provides a simple @R6$. The bash shell, which is another name
forthe command line interface that we&ve discussed in this
book, is also a @R6$. !nteractive interfaces for scripting
languages such as @uby, 6erl, 6ython, and 616 are commonly referred
to as @R6$Teven more so than database clients and command line
shells. These @R6$s read user input, evaluate it using the
scripting language&s interpreter, print the result of the
programming statement, then provide a prompt for more input.!n your
console, try using the irb @R6$. !f @uby is installed, you should
see something like this./ irbJJirb"main%.QQ*.QZYust as with the
mys9l program, irb provides a prompt. 5s you can see in the
following image, the irb program evaluates input, then performs
what the input tells it to do, then outputs the result of what it
did./ irbirb"main%.QQ*.QZ a \ *\Z *irb"main%.QQ3.QZ puts 01ello,
worldX01ello, worldX\Z nilirb"main%.QQ7.QZ!f you type a multi(line
script, it will automatically postpone evaluating the input until
the statement is nished./ irbirb"main%.QQ*.QZ a \ *\Z
*irb"main%.QQ3.QZ if a \\ 3irb"main%.QQ7.*Z puts 05 is
30irb"main%.QQ>.*Z elseirb"main%.QQB.*[ puts 05 is not
30irb"main%.QQE.*Z end5 is not 3\Z nilJNirb"main%.QQJ.QZType e'it
to leave irb.Other scripting languages, such as 1askell, 6ython,
and 616, also provide @R6$s. 5s you learn to program, you will nd
that @R6$s are very useful for e'perimenting with what you learn
andfor performing small computational tasks.(ditorsSome programmers
use the command line as their !;R "!ntegrated ;evelopment
Rnvironment%. 6art of that !;R is the te't editor, of which there
are several available for the commandline. The following interfaces
may look familiar.J?The above screenshots are all of te't editors
that are often used on the command line. When you see other
developers working ininterfaces like the ones above, they are
probably not in the mainshell @R6$ "the command line%, and are
instead using a te't editor program within the command line.NQ=ote.
!f you start typing command line commands while in an editor, those
commands may be treated as normal te't, or may be treated as editor
commands. Watch out for thatX 2ou must e'it the editor mode, and be
back in the command line to issue command line "or 0bash0%
commands.The process of e'iting is di+erent for each of the editors
mentioned above. 4elow is a list of the commands to e'it each
editor.-imR'it and save.`RS#Z L .w9R'it without saving.`RS#Z L
.9X,anoR'it and save.`#trlZ L o then `RnterZ, then `#trlZ L 'R'it
without saving.`#trlZ L ' then n to discard changes(macsR'it and
save.N*`#trlZ L ', `#trlZ L s, then `#trlZ L ', `#trlZ L cR'it
without saving.`#trlZ L ', `#trlZ L c, then n, `RnterZ and yes,
`RnterZ to discard any changes.Bash9 a #$ecial InterfaceSometimes,
you may end up in a situation where you&re working in a
0command line within a command line0. This is because the command
line interface we&ve been working in is itself a special
interface that can be nested. :or e'ample, while using the command
line you may think that you&re in the normal commandline
interface, but when you type e'it and hit enter, you remain what
appears to be another #$!. This is most likely because you&ve
unknowingly entered another bash "or shell% interface. When on the
command line, typing bash, Msh, or similar will createa new nested
shell interface for you to work in. 2ou can e'it the innermost
0shell0 by typing e'it. When you&re in the outermost shell and
you type e'it, you&ll see something like F6rocess completedG
without a way to enter more commands. 2ou&ll have to close and
restart Terminal at this point and start a new shell. !f you&re
working normally, you should very rarely encounter a nested command
line situation, but it can happen.#ummar&When you open up
Terminal and start using it, you may not always be using the
default command line. bash. 6rograms N3like mys9l, vim, and irb
provide interfaces of their own right within Terminal. !t&s
very important to understand whether you&re in an
application(specic @R6$, like mys9l, or if you&re in the bash
shell @R6$ "aka, the command line%. Sometimes, the only clue you
have is the prompt. 4ut as we&ve seen earlier, we can even
modify the prompt by setting the 6S* environment variable, so it
can be 9uite tricky.ConclusionOverview of Conce$ts1opefully by this
point, the command line is a bit less intimidating. While we&ve
covered the basic concepts of the command line in this book,
there&s a lot more to learn. 4ut don&t get discouragedX 2ou
have all the tools you need to become an adept #$! user. this book,
the man command to get more information about commands, and your
favorite search engine.$et&s brieSy review the concepts we
discussed in this book.: 'he command line is an interface to
&our com$uter's ;les and directories1The command line provides
a way to communicate with your computer. !ts language takes the
form of te't(based input and output.: (ver&thin! &ou do in
the command line is related to ;les< directories< and
e)ecutables1N7When working in the command line, everything is a le,
a directory, or an e'ecutable "and e'ecutables are les%. When you
run commands such ascd or ls, you are really Iust e'ecuting les.:
(nvironment variables $rovide conte)t for what &ou do in the
command line1#onte't for the commands you run is provided by
environment variables. 2our 0current directory0 "6W;%, the list of
directories that denes the location of e'ecutables "65T1%, and your
home directory "1OMR% are e'amples of environment variables that
a+ect the commands you run and your ability to run commands. 2ou
can change environment variables on the Sy using
theA5@!54$R\0value0 pattern, or you can set them more permanently
bye'porting the variables in your DK.bashrc le.: Access to ;les<
directories< and e)ecutables is determinedb& their read<
write< and e)ecute $ermissions1 'here are $ermissions for the
;le's user 7owner8< !rou$< and other 7ever&one
else815nother important piece of conte't is the user account you
are currently logged in under. Rach directory and each le is
assigned to a user and a group, and permissions for reading,
writing, and e'ecuting are granted to the user and group that are
assigned to that directory or le. 6ermissions are also granted to
everyone else "0other0%, which includes any user that is not the
user or doesn&t belong to the le&s group.N>: #ome
$ro!rams $rovide a com$letel& new conte)t within the command
line interface1While the environment variables and your user
account provide conte't for commands that you run while in the
command line interface, some commands can temporarily take over
handling all input and output. These commands allow users to
interact more directly with databases, les, and scripts. They
change the display and accept commands that aren&t available in
the regularcommand line interface, and commands that are available
in theregular #$! aren&t available in these other interfaces.
Some of these interfaces are called 0@R6$s0 because they @ead
input, Rvaluate the input, 6rint the results, and $oop back to read
more input.Where to o from HereWith the basic command line skills
you learned in this book, you are prepared to begin learning to
program. #ontinue to practice what you&ve learned and
e'periment with the command line so that you can retain and improve
on what you&ve learned. The more you use the command line, the
easier it will get, and the more powerful you will become in your
ability to make your computer do your bidding.NB