Managing User Accounts and User Environments in Oracle® Solaris 11.2

Exit Print View

Updated: September 2014
 
 

PATH Environment Variable

When the user executes a command by using the full path, the shell uses that path to find the command. However, when users specify only a command name, the shell searches the directories for the command in the order specified by the PATH variable. If the command is found in one of the directories, the shell executes the command.

A default path is set by the system. However, most users modify it to add other command directories. Many user problems related to setting up the environment and accessing the correct version of a command or a tool can be traced to incorrectly defined paths.

Setting Path Guidelines

    When setting up PATH variables, note the following guidelines:

  • If you must include the current directory (.) in your path, place it last. Including the current directory in your path is a security risk because some malicious person could hide a compromised script or executable in the current directory. Consider using absolute path names instead.

  • Keep the search path as short as possible. The shell searches each directory in the path. If a command is not found, long searches can slow down system performance.

  • The search path is read from left to right, so you should put directories for commonly used commands at the beginning of the path.

  • Make sure that directories are not duplicated in the path.

  • Avoid searching large directories, if possible. Put large directories at the end of the path.

  • Put local directories before NFS mounted directories to lessen the chance of the system becoming nonresponsive when the NFS server does not respond. This strategy also reduces unnecessary network traffic.