Q & A

  • GNULinux
  • 2 years ago

Environment variables in Unix are a set of dynamic named values that can affect the way running processes will be have on a computer.(Wiki defenition)

Different ways to get the environment variables:
To display a single variable value

echo $<VARIABLE NAME>
eg: echo $PATH

Commands for displaying all environment variables and their values

#env

or

 #set

or

  #printenv


Here is the sample output:

[environment variables]
env and set can also be used for setting the environment variables depending on the shell

Setting environment variable
In c shell(csh & tcsh)

setenv testpath=/usr/local/java/bin


In Bourne shell(sh & bash)

export testpath=/usr/local/java/bin

 

In kshell

testpath=/usr/local/java/bin;export testpath