February 2004
Beginner
200 pages
5h 40m
English
A very important variable is PATH, which instructs the shell where to find programs. When you type any command:
$ who
the shell has to find the program(s) in question. It consults the value of PATH, which is a sequence of directories separated by colons:
$ echo $PATH /usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/smith/bin
and looks for the who command in each of these directories. If it finds who (say, /usr/bin/who), it runs the command. Otherwise, it reports:
bash: who: command not found
To add directories to your shell’s search path temporarily, modify its PATH variable. For example, to append /usr/sbin to your shell’s search path:
$ PATH=$PATH:/usr/sbin
$ echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/smith/
bin:/usr/sbinTo make this change permanent, modify the PATH variable in your startup file ~/.bash_profile, as explained in Tailoring Shell Behavior. Then log out and log back in.