)
Using Shell Environment Variables
Every active shell stores pieces of information that it needs to use in what are called environment
variables. An environment variable can store things such as locations of configuration files, mailboxes,
and path directories. They can also store values for your shell prompts, the size of your history
list, and type of operating system.
To see the environment variables currently assigned to your shell, type the declare command.
(It will probably fill more than one screen, so type declare | more. The declare command also
shows functions as well as environment variables.) You can refer to the value of any of those
variables by preceding it with a dollar sign ($) and placing it anywhere on a command line. For
example:
$ echo $USER
chris
This command prints the value of the USER variable, which holds your username (chris).
Substitute any other value for USER to print its value instead.
Common Shell Environment Variables
When you start a shell (by logging in or opening a Terminal window), a lot of environment variables
are already set. Table 2-7 shows some variables that are either set when you use a bash shell
or that can be set by you to use with different features.
60
Linux First Steps Part I
TABLE 2-7
Common Shell Environment Variables
Variable Description
BASH Contains the full path name of the bash command.
Pages:
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210