Citing this source,
Standard UNIX variables are split into
two categories, environment variables
and shell variables. In broad terms,
shell variables apply only to the
current instance of the shell and are
used to set short-term working
conditions; environment variables have
a farther reaching significance, and
those set at login are valid for the
duration of the session. By
convention, environment variables have
UPPER CASE and shell variables have
lower case names.
To list all environment variables, use
printenv and to list all shell variables, use
You’ll note that the environment variables store more permanent value, e.g.:
Which changes quite seldom, while the shell variables stores local, temporary, shell-specific values, e.g.:
which changes every time you change your current directory.
For most practical tasks, set environment values by adding
export VARIABLE_NAME=VALUE to your ~/.bashrc file.