- Path (variable)
PATH is an
environment variable onUnix-like operating system s,DOS ,OS/2 , andMicrosoft Windows , specifying a set of directories where executable programs are located. In general, each executing process or user session has its own PATH setting.Unix and Unix-like
On
POSIX and Unix-like operating systems, the$PATH
variable is specified as a list of one or more directory names separated by colon (:
) characters. [Open Group Unix Specification, Environment Variables [http://www.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap08.html#tag_08_03] ] [Open Group Unix Specification,execve()
function [http://www.opengroup.org/onlinepubs/000095399/functions/execve.html] ]The
/bin
,/usr/bin
, and/usr/local/bin
directories are typically included in most users' path setting (although this varies from implementation to implementation). The current directory (.
) is usually included as well, allowing programs residing in thecurrent working directory to be executed directly. Superuser (root) accounts as a rule do "not" include it in the path, however, in order to prevent the accidental execution of scripts residing in the current directory. Executing such a program requires the deliberate use of a directory prefix (./
) on the command name.When a command name is specified by the user or an exec call is made from a program, the system searches the path, examining each directory from left to right in the list, looking for a
filename that matches the command name. Once found, the program is executed as a child process of the command shell or program that issued the command.DOS, OS/2, and Windows
On DOS, OS/2, and Windows operating systems, the
%PATH%
variable is specified as a list of one or more directory names separated by semicolon (;
) characters. [Microsoft.com, PATH command [http://msdn.microsoft.com/en-us/library/aa922003.aspx] ]The Windows system directories (typically
C:WINDOWSsystem32
) is typically the first directory in the path, followed by many (but not all) of the directories for installed software packages. Many programs do not appear in the path as they are not designed to be executed from a command window, but rather from aGUI interface.When a command is entered in a command shell or a system call is made by a program to execute a program, the system first searches the
current working directory and then searches the path, examining each directory from left to right, looking for anexecutable filename that matches the command name given. Executable programs havefilename extension s ofEXE
orCOM
, and batch scripts have extensions ofBAT
orCMD
. Other executable filename extensions can be registered with the system as well.Once a matching executable file is found, the system spawns a new process in which to run it.
References
Wikimedia Foundation. 2010.