PATH

Of all the operating system and environment concepts that it is important for you to understand, PATH is probably the most important. It functions virtually the same under Windows and Linux/Unix. PATH is very simple. It is an environment variable that lists the directories in which the system looks to find the command you have just entered. If it does not find the command (or program) in any of these PATH directories, it returns an error and tells you it cannot find the command or program you requested. Most computer systems have hundreds or thousands of directories... it would be impossible (or at least VERY slow) to check in every single directory for the command you are calling. Instead, a few directories are specified (by convention) to hold your executable programs and scripts (batch files) and the O/S (actually your shell) looks in only these directories. This is why the computer responds so quickly to your orders.

A typical PATH in Linux/Unix might be:

 

/bin:/usr/bin:/usr/$HOME/bin

(HOME is just another environment variable that is substituted automatically when the PATH value is obtained. This variable may be set to "tracy", "bill", "root", etc. (See Unix=.profile, Windows = fpplus.bat, fulldev.bat, user.bat, etc. )

 

A typical PATH in Windows might be:

 

C:\WINDOWS;C:\WINDOWS\COMMAND

It is important that you know where your executable scripts (or batch files under Windows) live. If they are not inside a PATH directory, they will not be found unless you were to issue their "full" pathname either at the command line or within your executable scripts. However, if the executable program you want is within a PATH directory you can just call it by name, the system will automatically find it and execute it, as in:

sort filename

Under Unix the "sort" command would be found in /bin. Under DOS, it would be found under C:\WINDOWS\COMMAND, assuming these directories were in the PATH variable list, the system will easily find the command for you and execute it. Otherwise, to operate the program, you would have to issue the command as:

 

Linux or Unix   /bin/sort
Windows C:\WINDOWS|COMMAND\SORT

The PATH variable is great shorthand for the user and the computer.