The PATH variable
The PATH variable determines where the system looks for the commands you want to run.The error message
Command not found
means that no executable file of that name was found in your PATH.
You should feel free to add directories to your PATH, but if you do you should bear the following in mind:
- •Don't replace the default path with a hard-coded version.
- We change things around from time to time, and hard-coded paths may cause old programs to fail and new ones not to be found.
- (We post about standard changes in the newsgroup panix.upgrade. Changes that affect large numbers of our users, especially those who are unlikely to read the panix.* newsgroups, are announced in MOTDs, and sometimes even in individual email to affected subscribers.)
-
- We may make two kinds of changes:
- •We may add programs to /usr/local/bin to be used in preference to programs of a similar name in other directories.
- •We may add directories to the default path. (This is less likely, but it has happened in the past.)
- To include the default path in your PATH, use the variable ${PATH} in the list. You can put this at the beginning, in the middle, or at the end of the list, as you prefer.
- •The order of the directories listed in your PATH will determine which version of a command you run. If you have a bin directory of your own, for instance, and a command called calendar in your bin directory, you will run your own calendar if your bin precedes /usr/bin in the PATH setting, and you will get the system command from /usr/bin otherwise.
-
In other words:
PATH=${PATH}:${HOME}/bin will give you /usr/bin/calendar
PATH=${HOME}/bin:${PATH} will give you ~/bin/calendar
(assuming that you have such an executable file). - This leads to an important security consideration:
- • Someone who manages to leave a file in a directory that's in your path can write a nasty program and give it a name that duplicates a common command (like ls or cat). If that directory comes before /usr/bin in your PATH, you'll run that command instead of the real one. Or you might find a common typo (like "mial") in a directory anywhere in your path that could have a bad program in it.
- •We therefore recommend against putting . (the current directory) in your PATH, or, if you must have it, put it at the end. You should also make sure that no directory in your PATH is writable by "other" or by group "users" to avoid the likelihood of this happening.
- • You can use the setup command to add directories to your PATH.
Last Modified:Thursday, 31-Jan-2013 15:21:11 EST
© Copyright 2006-2021
Public Access Networks Corporation