Environment variables

Many applications use environment variables to control their behavior.

For example, less gets the width of the terminal or window from the COLUMNS environment variable; many utilities write any temporary files in the directory specified by TMPDIR. For more information, see the Commonly Used Environment Variables appendix of the Utilities Reference.

When you start a process, it inherits a copy of its parent's environment. This means that you can set an environment variable in your .profile, and all your shells and processes inherit it—provided that no one in the chain undefines it.

For example, if you have your own bin directory, you can add it to your PATH by adding a line like this to your .profile:

export PATH=$PATH:/home/username/bin

If you're the system administrator, and you want this change to apply to everyone, export the environment variables from /etc/profile or from a script in /etc/profile.d. For more information, see the discussion of /etc/profile earlier in this chapter.