Next: Command Arguments
Up: Shells
Previous: Executing Commands
Programs may live anywhere and it would be too time consuming for a
shell to search all directories. Furthermore, what would happen if
there were more than one executable by the same name?
The PATH evironment variable contains a colon-delimited list of
directories in which commands may be found. When a user types a command
that is not builtin, the shell searches all of the directories in the
PATH variable, in order. A typical PATH variable is
$HOME/bin:/usr/local/bin:/usr/bin/X11:/usr/bin
.
You can see your path (or any variable) by typing
eg1$ echo $PATH
Once a command is found, its location is remembered in a hash.
Subsequent invocations check the hash before searching directories in
PATH. If the PATH variable is changed, the user may have to manually
erase the hash with
$ hash -r
[csh: rehash
]
Reece Kimball Hart
1998-03-18