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 set
.
You'll note that the environment variables store more permanent value, e.g.:
HOME=/home/adam
Which changes quite seldom, while the shell variables stores local, temporary, shell-specific values, e.g.:
PWD=/tmp
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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…