Each Unix flavor comes pre-loaded with a set of system defined environment variables such as $HOME, $PATH and $SHELL.
Environment varibales are system specific variables whose values can be changed by the user and are available globally throughout your terminal.
If one wishes to view the value of a specific variable, one can just echo the variable name. You can also find out all the available shell environment variables in following way:
Viewing the environment variables The printenv command is used to view all the environment variables
$ printenv The above example is also illustrated by below screenshot:
printenv command (click on the image to enlarge).
Setting an environment variableOne can set a new environment variable just like any other other variable
. However, one must export the variable to make it globally available.
$ MYHOMEPATH=$HOME/vishal/home$ export MYHOMEPATHTo unset a variable, simply type unset variable_name, as shown in below example.
$ unset MYHOMEPATH
Published on December 06, 2015 12:43