Today: 07/08/2008
 

Working with BASH environment variables (simple commands for beginners)

You'll learn the following in this tutorial.

I have tried instructions below on Ubuntu Server but should work for all distributions running the BASH shell.

Display names and values of all environment variables

env

Assign value to an environment variable

TESTVAR=value

Example:

TESTVAR=/usr/local/sbin:/usr/local/bin

Command above assigns the value "/usr/local/sbin:/usr/local/bin" to the TESTVAR variable.

Print value of a particular environment variable

echo $<variable name>

Example:

echo $TESTVAR

Command above prints the value of BASH's TESTVAR variable.

Append value to an existing environment variable:

<variable name>=$<variable name>:<new value>

Example:

TESTVAR=$TESTVAR:/bin

Command above appends "/bin" to the value of BASH's TESTVAR variable.

Make the variable globally accessible:

export <variable name>

Example:

export TESTVAR

Delete an environment variable:

unset <variable name>

Example:

unset TESTVAR

=======================================================================================

Support Techs Worldwide:

Link to us:

You can support us by putting a link to our website on your blog or website (code is below).

<a href="http://www.techsww.com">
Techs Worldwide - Tutorials about Software Installation,
Configuration, Administration, Monitoring, Tools, Tips &
Tricks
</a>

OR a simple one.

<a href="http://www.techsww.com">
Techs Worldwide - IT related Tutorials
</a>

Feedbacks:

We appreciate feedbacks and suggestions about our tutorials and Techs Worldwide from readers. Please contact us using the form here and let us know what you think about the tutorial and the website in general.

Bookmark Us:

We are working on new features for the website, please keep visiting or bookmark us using your favourite bookmarking service.

Subscribe to RSS:

You can subscribe to our RSS feed here.

 
 
Creative Commons License   Valid XHTML 1.0 Transitional Valid CSS