CHAPTER 7

image

Treading a Righteous PATH

The PATH variable is a colon-separated list of directories that your shell will search for a command. It usually includes /bin, /usr/bin, and /usr/local/bin. If you are root, it will also include /sbin and /usr/sbin. There may be other directories, and there may even be a dot, which puts your current directory in the PATH. For example, a typical user’s $PATH looks like this:

/usr/bin:/bin:/usr/local/bin:/usr/games:/usr/X11R6/bin:/home/chris/bin

Whenever you enter a command without a full path (e.g., ls instead of /bin/ls), the shell searches the directories listed in your PATH variable for the command. If all ...

Get Shell Scripting Recipes: A Problem-Solution Approach, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.