Finding the Path
- 0
- Add a Comment
Finding the Path
A week or so ago, we talked about modifying the PATH variable to add a directory. This variable makes it possible to use relative rather than absolute pathnames in your commands. For instance, if your PATH variable includes the directory /usr/bin, all the executable programs in that directory will be available simply by entering the command name.
Is there a quick and easy way to find out which directories are included in the PATH variable? You bet there is. A simple two-word command will echo all the directories in the PATH variable out to the screen.
echo $PATH
What you’re likely to see returned as the result of this command is something like this:
/usr/local/bin:/usr/bin:/usr/X11R6/bin:.
This is a complete list of all the directories the PATH variable searches for the command you’ve entered. Each is separated from the next by a colon. If you have the same command in different PATH-defined directories, only the first will be searched. In other words, PATH only looks as far as it needs to for a command.
Thanks to PATH, you don’t have to look for most commands at all.
