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 :
printenvorenv - To view ONE environment variable :
echo $envNamefor e.g.,echo $SHELL - To set the environment variables temporarily :
export TEST=1echo $TEST
- To set the environment variable permanently
- Open the shell config file, for e.g.,
.bashrcin Terminal or any text editor and place the environment variable there. Then source the config file bysource .bashrcor restart the shell environment with updated config file byexec bash - Example :
vim .bashrcthen add the following lines.TEST=1export $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/profileor/etc/bashrc