Skip to Main Content
Linux Pocket Guide
book

Linux Pocket Guide

by Daniel J. Barrett
February 2004
Beginner content levelBeginner
200 pages
5h 40m
English
O'Reilly Media, Inc.
Content preview from Linux Pocket Guide

Search path

A very important variable is PATH, which instructs the shell where to find programs. When you type any command:

$ who

the shell has to find the program(s) in question. It consults the value of PATH, which is a sequence of directories separated by colons:

$ echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/smith/bin

and looks for the who command in each of these directories. If it finds who (say, /usr/bin/who), it runs the command. Otherwise, it reports:

bash: who: command not found

To add directories to your shell’s search path temporarily, modify its PATH variable. For example, to append /usr/sbin to your shell’s search path:

$ PATH=$PATH:/usr/sbin
$ echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/smith/
bin:/usr/sbin

To make this change permanent, modify the PATH variable in your startup file ~/.bash_profile, as explained in Tailoring Shell Behavior. Then log out and log back in.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Linux Pocket Guide, 2nd Edition

Linux Pocket Guide, 2nd Edition

Daniel J. Barrett
Linux in a Nutshell, 6th Edition

Linux in a Nutshell, 6th Edition

Ellen Siever, Stephen Figgins, Robert Love, Arnold Robbins

Publisher Resources

ISBN: 9780596806347Errata Page