DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Customizing your environment

Setting your path

Each command you type is actually a program that is stored somewhere on the computer. When you type a command and press <Enter>, your shell looks through all the directories in your path until it finds a program with the same name as the command you typed.

When you see a message like ``not found'', it means your shell could not find the command in any of the directories listed in your path. If you see a ``not found'' message for a command that you know exists, ask your system administrator what directory the command lives in, then add that directory to your path definition. In the meantime, you can type the full pathname of the command, for example, /usr/bin/finger. When you use the full pathname of a command, you tell the shell exactly where the command lives, so it does not search through the directories in your path definition.

A typical path setting in a sh or ksh .profile might look like this:

   PATH=/bin:/usr/bin:$HOME/bin:.
This says ``set the path to look in the bin directory, then /usr/bin, then the bin directory in the home directory, and finally, in the current directory.''

The same path setting in csh .login would be:

   set path=(/bin /usr/bin $HOME/bin .)
To add a directory to your path, simply edit the path statement in your .profile, .login, .kshrc, or .cshrc to contain the new directory. For example, to add the directory /usr/company/bin to your path in sh or ksh, you could change your path statement to read:
   PATH=/bin:/usr/bin:/usr/company/bin:$HOME/bin:.

Q: Why would I want to put a new directory in the middle of the path definition instead of at the end?

A: You control the order in which directories are searched by the order you put those directories in the path definition. In general, you want to put nonstandard directories, like your company bin and your personal bin, after the standard /bin and /usr/bin. This is because most of the commands you want to use are in these standard directories, so putting them at the beginning of your path means your shell finds them more quickly.

Q: My path setting contains the PATH variable itself:

PATH=$PATH:$HOME/bin
What does this mean?

A: A path setting like this says ``set the path to the current path, then add in the bin in my home directory.'' When you log in, your shell first reads definitions from the system-wide profile /etc/profile. If your system has been set up so that /etc/profile contains path definitions, including $PATH in your path definition ensures that your shell knows about any system-wide path definitions.


Next topic: Default file permissions
Previous topic: Changing your prompt

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 03 June 2005