Datasheet

42
Phase 1
Working on the Command Line
condition and try again with another file; it may take a bit of trial and error to locate the correct
file. If you like, you can change the global configuration file to affect all users, but you must do
so as root.
In addition to startup scripts, bash provides shutdown (or logout) scripts. The most com-
mon name for this script is ~/.bash_logout, which is a user script. Modifying this or similar
scripts can be handy if you want to ensure that certain actions are taken when a user logs out.
You might use it to destroy sensitive temporary files, for instance.
Exploring Other Environment Variables
Linux supports many more environment variables than the $PS1 and $EDITOR variables described
earlier. In fact, you can set any environment variable you want—$PHASE1 or $GOBBLEDEGOOK, for
instance. To be useful, though, an environment variable must be used by bash or by some other
program. Table 1.5 summarizes some common environment variables and their uses. This table is
not comprehensive, though; in principle, any program may use its own unique environment vari-
ables. If you read in a program’s documentation that it uses particular environment variables, you
can set them using the techniques described earlier.
TABLE 1.5 Common Environment Variables and Their Meanings
Variable Name Explanation
$USER This is your current username. It’s a variable that’s maintained by
the system.
$SHELL This variable holds the path to the current command shell.
$PWD This is the present working directory. This environment variable is
maintained by the system. Programs may use it to search for files
when you don’t provide a complete pathname.
$HOSTNAME This is the current TCP/IP hostname of the computer.
$PATH This is an unusually important environment variable. It sets the path
for a session; the path is a colon-delimited list of directories in which
Linux searches for executable programs when you type a program
name. For instance, if PATH is /bin:/usr/bin and you type ls, Linux
looks for an executable program called ls in /bin and then in /usr/
bin. If the command you type isn’t on the path, Linux responds with
a command not found error. The $PATH variable is typically built up in
several configuration files, such as /etc/profile and the .bashrc
file in the user’s home directory.
$HOME This variable points to your home directory. Some programs use it
to help them look for configuration files or as a default location in
which to store files.
83484.book Page 42 Monday, September 18, 2006 8:58 AM