Menu Close

The Golden Path…

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:

  1. Start the System Control Panel applet (Start – Settings – Control Panel – System).
  2. Select the Advanced tab.
  3. Click the Environment Variables button.
  4. Under System Variables, select Path, then click Edit.
  5. 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
  6. 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.
  7. 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:
echo $PATH
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 /usr2/username/bin, then /usr/local/bin, then /usr/bin, and finally the local directory, indicated by the  .  (a period).

To modify your path

If you are using csh or tcsh, at the shell prompt, enter:
setenv PATH $PATH\:/dir/path
If you are using sh, ksh, or 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 $PATH\:/dir/path with /dir/path:$PATH .
To make these changes permanent, add the commands described above to the end of your .cshrc file (for csh and tcsh), .profile file (for sh and ksh), or .bash_profile file (for bash).

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.