Last modified on 12 May 2010, at 10:57

Bourne Shell Scripting/Appendix B: Environment reference

In the section on the environment we discussed the concept of environment variables. We also mentioned that there are usually a large number of environment variables that are created centrally in /etc/profile. There are a number of these that have a predefined meaning in the Bourne Shell. They are not set automatically, mind, but they have meaning when they are set.

On most systems there are far more predefined variables than we list here. And some of these will mean something to your shell (most shells have more options than the Bourne Shell). Check your shell's documentation for a listing. The ones below are meaningful to the Bourne Shell and are usually also recognized by other shells.

Bourne Shell environment variables
Variable Meanings
HOME The user's home directory. Set automatically at login from the user's login directory in the password file
PATH The default search path for executables.
CDPATH The search path used with the cd builtin, to allow for shortcuts.
LANG The directory for internationalization files, used by localizable programs.
MAIL The name of a mail file, that will be checked for the arrival of new mail.
MAILCHECK The frequency in seconds that the shell checks for the arrival of mail.
MAILPATH A colon “:” separated list of file names, for the shell to check for incoming mail.
PS1 The control string for your prompt, which defaults to “$ ”, unless you are the superuser, in which case it defaults to “# ”.
PS2 The control string for your secondary prompt, which defaults to “> ”. The secondary prompt is what you see when you break a command over more than one line.
PS4 The character string you see before the output of an execution trace (set -x); defaults to “+ ”.
IFS Input Field Separators. Basically the characters the shell considers to be whitespace. Normally set to 〈space〉, 〈tab〉, and 〈newline〉.
TERM The terminal type, for use by the shell.