The Path to Unix Enlightenment
Unix needs some guidance to get things done for you. It is led through the maze of the file system hierarchy by a "path". Different functions use different paths to find commands or files. These are set for you by default and you may have no need to change them. A few modifications can simplify your work, however.
A path contains a list of directories. The directories in each path are searched in order from first to last until the requested program or file is found. This can be used to your advantage if you want to override a system program by putting your copy in the path first. It can also cause confusion if you inadvertently name a program using a system command name and get in your path before the system commands are reached. A little care can avoid this problem.
Here are four very useful paths.
PATH (called "path" in the C-sh)
This is the list of directories which Unix searches to find programs. It includes directories for system commands, compilers, and commands which were added locally. If you create or download programs of your own, you can put them in a directory and add that directory to your path. To add a directory named "bin" which is in your home directory to the end of your path (in the Korn shell) use
PATH=$PATH:~/bin
export PATH
in your ".profile" (see Tipsheet Vol. 1, No. 3 for more information on this). This directory name has no special meaning, but it is a traditional name where users place programs of their own to be executed. If you have a program which you want Unix to find, regardless of which directory you are in, you could put it in a "bin" subdirectory of your home directory. Traditionally, users have added "the current directory" to the end of the path. It is designated with ".", so our previous example would be expanded to
PATH=$PATH:~/bin:.
export PATH
Here is the default path:
/usr/bin:/usr/local/bin:/opt/SUNWspro/bin:/usr/dt/bin:/usr/openwin/bin:
/usr/ccs/bin:/usr/ucb:/usr/local/teTeX/bin/sparc-solaris2.5.1:
/opt/Java-WorkShop2.0/JDK/bin:/opt/Java-WorkShop2.0/JWS/sparc-S2/bin
(Editor's note: As of January 27, 2003, the default path on
bama is
/usr/local/bin:/usr/bin:/opt/Workshop/WS6U2/SUNWspro/bin:
/usr/dt/bin:/usr/openwin/bin:/usr/ucb:/usr/ccs/bin:
/usr/local/teTeX-1.0.7/bin/sparc-sun-solaris2.7:/opt/schily/bin:
/usr/local/ncarg/bin:/usr/java/bin:
/opt/Java-WorkShop3.0/sparc-S2/bin:/usr/local/netscape:
/usr/G11R6.1/bin)
CDPATH (called "cdpath" in the C-sh)
This path guides the "cd" command when you want to change directories. If you have directories that are widely separated in the hierarchy, this will simplify moving around. When you issue the "cd" command all the directories in CDPATH are searched in addition to the current directory, for the new directory. The first directory name that is found to match the desired directory is the one to which you will go.
There is no default CDPATH. If you are using the Korn shell, you would set it in your ".profile" file with
CDPATH=.:~/my-sub-dir1:~/my-sub-dir2/sub-sub
export CDPATH
where "." is Unix shorthand for the current directory and "~" is Unix shorthand for your home directory. You should substitute for "my-sub-dir1" and "my-sub-dir2/sub-sub" with the subdirectories and sub-subdirectories you want to include.
MANPATH (also called MANPATH in the C-sh)
The MANPATH guides the "man" command, which is the Unix help command. Users rarely need to make changes to this, but if you happen to add software of your own and it comes with a man page, you would want to add the appropriate directory to the end of the MANPATH.
/usr/man:/usr/local/man:/usr/openwin/man:/usr/openwin/share/man:
/usr/dt/man:/opt/SUNWspro/man:/usr/local/teTeX/man:/usr/local/opt/man
MAILPATH (called "mail" in the C-sh)
This can be a very useful path if you are directing your mail into different folders on Bama with PROCMAIL (see Tipsheet Vol. 1, No. 5). The mail delivery system on Bama uses this path name to check files for new mail. If new mail arrives and you are logged on to the system, you will be sent a notification that mail has arrived . It can also be used if you are supposed to be monitoring mail for an organization or a special departmental account while you are logged in. You can add those other mail files to the end of MAILPATH
This is currently set to your home mailbox (~/.newmail). If you monitor mail for an organization you could do
MAILPATH=~/.newmail:/fs/myorg/.newmail
export MAILPATH
where you would substitute for "/fs/myorg" with the home directory of the relevant account.
If you are using the C-sh, the technique used to set these paths is a bit different. You would use the form
set path=(the actual path list)
where path is "path", "cdpath", or "mail" and the directory names are surrounded by "(" and ")" and separated by spaces, or
setenv PATH the:actual:path:list
where PATH is "MANPATH" and the directories are separated by ":"
© 1998, The University of Alabama. The information included here is for the University of Alabama central computing facility as it was configured on the document date. It may or may not apply to other Unix systems.

