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 type the name of a command.
For example, if you have no PATH
variable set and you want to copy a file, you need to type the full path name 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 that is named in the PATH
variable, and executes it when it is found. You can significantly streamline your work by using the PATH
variable to list the commonly used SunOS
command directories.
For the Bourne, Bourne Again, and Korn shells, you can specify the PATH
variable in your user profile file (in your home directory) by using the following syntax.
PATH=.:/usr/bin:/home/bin |
In the previous example, home represents the path name of your home directory.
For the C, TC, and Z shells, you can specify the PATH
variable in your user profile file (in your home directory) by using the following syntax:
set path=(/usr/bin home/bin .) |
In this command, home is the path name of your home directory.
In the C, Korn, TC, and Z shells 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, TC, or Z shell, use the source command to make the changes effective in your current window without having to log out:
example% source user-profile-file |
If you are running the Bourne, Bourne Again, or Korn shell, type the following to make the changes effective in your current window without having to log out:
$ . user-profile-file |