Linux 101 : Bash environment variables
- EDITOR="Nano"
- EDITOR="Vim"
- - - - - - -
By keeping the environment variable separate from the program, we can easily change them without the need to change the code of the program and recompile it.
Displaying environment variables:
To see all the environment variables we use the below command:
Displaying a particular variable:
If we want to display a variable like the "PATH" environment variable, we use the below:
or:
Remark:
The Environment variables are case-sensitive, "Path" and "PATH" are completely different variables.
Creating a new environment variable:
We create a new environment variable using:
Removing an environment variable:
We do that using the below command:
Persisting environment variable:
To be able to survive a reboot we will need to add our environment variable to the ".bash_profile" file in our home directory "~/.bash_profile" as below:
Comments