Environment Variables
An environment variable is a dynamic-named value that cam affect the way running process will behave on a computer. They are a part of the environment in which a process runs. For example, each user in an operating system has its own environment. An admin user has a different environment than other users do.
- To view all environment variables :
printenv
orenv
- To view ONE environment variable :
echo $envName
for e.g.,echo $SHELL
- To set the environment variables temporarily :
export TEST=1
echo $TEST
- To set the environment variable permanently
- Open the shell config file, for e.g.,
.bashrc
in Terminal or any text editor and place the environment variable there. Then source the config file bysource .bashrc
or restart the shell environment with updated config file byexec bash
- Example :
vim .bashrc
then add the following lines.TEST=1
export $TEST
- Open the shell config file, for e.g.,
- To set the global environment variable permanently make the similar process as above in the file
/etc/profile
or/etc/bashrc