What is an environmental variable?

It is a variable that has gone green of course. Ok so im totally kidding. An enviromental variable runs in the envoronment in which your script runs. In most cases we are talking about BASH when we talk about the environment.

You set a standard local variable in the shell by doing:

#makes a local variable availible to that script #not the shell.
myVar='someVal'  

Viewing whats going on in your environment:

To view whats going on just type: env | less. This will send the environmental variables out to the less utility which paginates the results. This is usefule because you can often have lots of environmental stuff set. You go to the next page with the spacebar. You quit the output with the q button.

To make a global environmental variable that bash uses you can use the export keyword like so: can view

#im availible to child processes in the shell
export myVar='someVal'  

If you want to set an enviromental variable availible for global use then you can do the above in your .bash_profile.

Resources

Bash environment 101