Shell Processes   «Prev 

PATH versus path difference

The PATH variable is sometimes confused with the term path in UNIX. A path is used to indicate the location of a file or a directory. So, the path to the ls file in the
/usr/bin directory is /usr/bin/ls. 

The path to the passwd file in the /etc directory is /etc/passwd.
PATH is a variable used to help the shell construct a path to the command you are running. Let us say your PATH variable has the following value:

/usr/bin:/export/home/susan

PATH is list of Directory Names

PATH is a list of directory names separated by colons. When you type in the ls command, the shell looks through each directory in your PATH for a file called ls. It finds an ls file in the /usr/bin directory. The shell then composes the path /usr/bin/ls and then runs your command. This happens in the background, so you will not see the shell do this.
Notice that in the example above, I have included the /export/home/susan directory in the PATH. If I create a script in
/export/home/susan
called “myscript”, I can run it using the command:

$myscript

The shell sees this command and starts searching through the directories in my PATH variable.
It will not find a file called myscript in
/usr/bin, 

so it keeps looking. It does find a myscript file in /export/home/susan. Once the file is located, the shell creates the path
/export/home/susan/myscript

and runs the script.