Shells and environment variables

Many programs running under Linux require information about you and your personal preferences to operate sensibly. Although you could manually provide this information to each program you run, much of the information you’d convey would be redundant because you’d be telling every command you enter the same ancillary information at each invocation. For example, you’d need to tell your paging program about the size and nature of your terminal or terminal window each time you use it. You would also need to give fully qualified directory names for the programs you run.

Rather than force users to include so much detail to issue commands, the shell handles much of this information for you automatically. You’ve already seen that the shell creates an operating environment for you. That environment is made up of a series of variables, each of which has a value that is used by programs and other shells. The two types of variables used by most shells are:

Environment variables

These variables can be thought of as global variables because they are passed on to all processes started by the shell, including other shells. This means that child processes inherit the environment. By convention, environment variables are given uppercase names. bash doesn’t require the case convention; it is just intended for clarity to humans. However, variable names are case-sensitive. Your shell maintains many environment variables, including the following examples:

PATH

A colon-delimited ...

Get LPI Linux Certification in a Nutshell, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.