Customizing the search path for commands: The PATH variable
Command interpreters usually have to search for a file that contains the command you want to run. When you are using the shell, you tell the shell where to search for a command. Essentially, the shell uses a list of directories in which commands may be found. This list is specified in your PATH variable in your etc/csh.cshrc file. The list could be called your search path, because it tells the shell where you want to search.
setenv path 'dir:dir:...'
or,
set path=(dir1 dir2)
For example, you might
enter: setenv path '/bin:/usr/bin:/usr/macneil/bin:/usr/games:/usr'
The
shell then searches the directories in the following order, when looking
for commands or shell scripts: - /bin
- /usr/bin
- /usr/macneil/bin
- /usr/games
- /usr
As soon as the shell finds a file with an appropriate name, it runs that file.
Because the shell runs a command as soon as it finds a file with an appropriate name, pay close attention to the order in which you list directory names in your search path. For example, the previous search path specifies the /bin directory (where shell commands are stored) before the /usr/bin directory.
If you set up your PATH incorrectly, you could get the wrong command. You should generally search the shell commands directory first: /bin.