Wednesday, May 13, 2015

Environment Variable


To see a shell’s variables, issue set command or run:
$ printenv
The scope of the variable is the shell in which it’s defined so to make a variable and its value available to other programs, you can enter:
$ export BPVAR   
Or the shortcut for defining and exporting simultaneously is:
$ export BPVAR=3
This variable is now called an environment variable because it is available to other programs in the shell’s environment. 

Example: To add directories to your shell’s search path temporarily, modify its PATH variable. For example, to append /usr/sbin run: 
$ PATH=$PATH:/usr/sbin
To make your change permanent, you should edit bash startup file which is a hidden file in the home directory: 
$ vi ~/.bash_profile 
Then log out and log back in to load the contents. 

Labels: ,