Chapter 4. Managing Your Working Environment

Table of Contents
Environment variables
Common environment variables
Changing .bashrc

Environment variables

The unix shells are programming environments, and because of this they have ways to define variables (names that can store data). Simple assignments can be made using the equals sign (=), and variables can be printed by preceding the name with a dollar sign ($). Variable assignments can be erased with unset. For example:

Example 4-1. Shell variable assignment


$ stuff=1
$ echo $stuff
1
$ unset stuff
$ echo $stuff

$

In addition to the variables that the shell supports for programming, there are variables that the user can use to customize the working environment. These are called environment variables. In bash, environment variables begin life as regular variables and are ``exported'' into the environment with the export command. Unlike regular variables, exported variables are visible to every program you run from the shell, so anything you customize has ``persistence'' as you run programs.