I know that
VARIABLE=value creates an environment variable, and
export VARIABLE=value makes it available to processes created by the current shell.
env shows the current environment variables, but where do they live? What comprises an environment variable (or an environment, for that matter)?
I know that
An environment is not as magical as it might seem. The shell stores it in memory and passes to the
Both of these GNU manpages match the POSIX specification
You've got it just a little wrong:
In some larger sense, an "environment" is just the information that goes along with program execution. In C programs, you might find the process ID with a
And this latter, stronger definition is what an "environment" is for Unix/Linux/*BSD shells: an association between names ("variables") and their values. For most Unix-style shells, the values are all character strings, although that's not as strictly true as it used to be. Ksh, Zsh and Bash all have typed variables these days.
The use of an environment separate from plain shell variables involves the
Unix environment is different from at least some other operating systems: VMS "lexicals" could be changed by a child process, and that change was visible in the parent. A VMS
Some environment variables are well known,
Environment variables in their rawest form are just a set of name/value pairs. As described in the bash man page (
In practical terms, it allows you to define behavior that is shared or unique to programs invoked from the present shell. For example, when using
Quite a lot of unix commands read the environment and depending on what is set there alter their output/processing/action depending on these. Some are shared, some are unique to the program. Most man pages contain information on how the environment variable have an effect on the described program.
Other practical illustrations are for things such as systems with several installs of Oracle on the same platform. By setting
bash itself has many environment variables which can change the behavior of a range of things from history (
Also you can write scripts/programs that make use of your own custom environment variables (to pass settings, or change functionality).
"Environment Variables" are a set of dynamic named values that can affect the way running processes will behave on a computer.
They are part of the operating environment in which a process runs. For example, a running process can query the value of the TEMP environment variable to discover a suitable location to store temporary files, or the HOME or USERPROFILE variable to find the directory structure owned by the user running the process.
More info here → http://en.wikipedia.org/wiki/Environment_variable.
Everything you want to know about Environment Variables... ↑
Hope it helps, good luck.