Common environment variables

Any program can make use of environment variables (check its man page or documentation to determine what variables it supports). However, there are some environment variables that are understood by many programs. They include:


specifies the editor that will be used by other programs, such as a mail program.


specifies the pager that will be used by programs, such as man, to display long files ``one page at a time.'' Common pagers are more and less.


specifies the directories that the shell will look in to find commands. The directories listed in the PATH are searched in the order in which they appear.


specifies the default printer to which the lpr command (the default printing command) will send output.


specifies the terminal (display) you are using. Common values are xterm, vt100, rxvt, and linux. Only occasionally will users find it necessary to set this by hand.

In bash, you can use the echo command to display the current settings of these variables, and the export command to set new values.

Example 4-2. Exporting variables in the shell

$ echo $EDITOR
$ export EDITOR=vim
$ echo $PAGER

$ PAGER=less
$ export PAGER

These settings would change the default editor from nano to vim, and define less as a default pager. Notice that the export command can be separate or combined with a variable assignment on one line.