Some binaries are used just too oftern to specify a path each time you want to run one. The file listing program is one such example (dir in Windows, ls in Linux). To get your shell to automatically search a certain directory for binaries without having to specify thier paths each time is simple enough. Most modern OSes include a PATH variable for just this reason. Updating this variable is a little different depending on your OS, but the steps for changing them on both Windows and Linux are listed below.
To change the system path, perform these steps:
- Start the System Control Panel applet (Start – Settings – Control Panel – System).
- Select the Advanced tab.
- Click the Environment Variables button.
- Under System Variables, select Path, then click Edit.
- You’ll see a list of folders, as this example for my system shows: C:\Program Files\Windows Resource Kits\Tools\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Support Tools\;C:\Program Files\Common Files\Roxio Shared\DLLShared;C:\Program Files\Common Files\Ulead Systems\MPEG;C:\Program Files\Intel\DMIX;C:\Program Files\Executive Software\Diskeeper\;C:\Program Files\Bonjour\;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Misc
- You can add additional folders that you want to include in searches. I add a “C:\program files\misc” entry into which I place my standalone utilities, instead of copying them into C:\windows. Click OK.
- You’ll need to restart the processes (e.g., command prompt) that use the system path to see the added folders.
An alternative to setting the path at system level is to change it at user level; however, doing so will affect only your logon session and not other users who might use the computer or system processes, which might cause confusion and unexpected behavior. You can also set the path at a system level by using the setx command with the -m switch.
To find out what your path is, at the Unix shell prompt, enter:
Your path will look something like the following.
You will see your username in place of
username. Using the above example path, if you enter the
ls command, your shell will look for the appropriate executable file in the following order: first, it would look through the directory
/usr/bin, and finally the local directory, indicated by the
. (a period).
To modify your path
If you are using
tcsh, at the shell prompt, enter:
setenv PATH $PATH\:/dir/path
If you are using
bash, at the shell prompt, enter:
PATH=$PATH\:/dir/path ; export PATH
In all cases, replace
/dir/path with the directory you want the shell to search.
Note: The earlier entries in the path take precedence over the later ones. If you want the directories you add to your path to take precedence, in the examples above, replace
To make these changes permanent, add the commands described above to the end of your
.cshrc file (for
.profile file (for
.bash_profile file (for