meta data for this page
This is an old revision of the document!
Environmental variables
Environmental variables are used to configure - guess what - your computer environment. They store information that is used by both the operating system and individual programs. Typically, environmental variables are written in all uppercase letters and are preceded by a $ sign. One prominent example is the variable
$PATH
It stores all paths where the operating system automatically looks for executable programs and scripts. If the path to a program you want to use is stored in $PATH, you can call this program from anywhere in the directory tree. For all other programs, the path to the executable file hast to be specified in the program call.
You can check for the value of an environmental variable by simply calling the function echo followed by the variable name
echo $PATH
If a program that is not in your default PATH is used many times, it might be convenient to add its location to $PATH by using the export command. For example,
export PATH=$PATH:/home/andreas/bin
adds the directory /home/andreas/bin to the paths stored in $PATH. Please note, that to the right of the equation sign we write both $PATH and the new path separated by a colon. If you omit the $PATH, you will overwrite the contents in $PATH.
Changing $PATH via the export function is valid only for the current terminal and for the ongoing session. The information will be lost once you change to another terminal, or when you close and restart the terminal. For a permanent modification of $PATH you will need to modify the configuration file.