When you first
log in to the host, you are placed in a predefined shell (the
interface between the user and the kernel). By entering the command
sh at the
command line you can start a second shell (called a subshell).
You can create as many subshells as you like and when you are
finished with each you can use the exit
command to close the subshell. The
behavior of each of these shells (the main shell or subshells)
can be modified by setting shell variables.
Stored
in memory, a shell variable is a place holder for information
that will be used later by system or user processes. These
variables can be either user-defined (set by the user), or built-in
(set by the system), and they
are used to hold such information as the default printer or the
path name to a specific directory.
Shell
variables can be either local or global (environment). Local variables
are available only in the shell in which they are created, global
variables are available in the shell in which they are created
and all subshells created thereafter. By default, all user-defined
variables are local. To make them global, the variables must be
added to an initialization file (as discussed in chapter 8) and
exported.