PATH
VariableThe PATH
environment variable is used to locate commands within the SunOS directory hierarchy. By setting the PATH
you create a fixed set of directories that the system always searches whenever you enter the name of a command.
For example, if you have no PATH
variable set and you want to copy a file, you need to enter the full pathname for the command, /usr/bin/cp. However, if you have set the PATH
variable to include the directory /usr/bin, then you can simply type cp and your system will always execute the command. This is because your system searches for the cp command in every directory named in the PATH variable, and executes it when it is found. Using the PATH
variable to list the commonly used SunOS command directories can thus significantly streamline your work.
For the Bourne and Korn shells, the PATH
variable is specified in your .profile file (in your home directory) using the following syntax:
PATH=.:/usr/bin:/home/bin |
where home represents the path name of your home directory.
For the C shell, the PATH
variable is specified in your .cshrc file (in your home directory) using the following syntax:
set path=(. /usr/bin home/bin) |
where home is the path name of your home directory.
In the C shell you can use the shortcut ~ to represent the path name of your home directory.
If you modify the PATH
variable, and you are running the C shell, use the source command to make the changes effective in your current window without having to logout:
example% source .cshrc |
If you are running the Bourne or Korn shell, type the following to make the changes effective in your current window without having to logout:
$ . .profile |