Environment Variables

Environment Variables

There are many environment variables. Some will be set automatically at login and some which you can change if needed. Many of the environment variables will be related to paths and storage locations, but there are also some which are set for specific applications (like compilers). These environment variables willl be set when you load the 'module' for the application in question. (Read more about modules in the section about them.)

You should use environment variables instead of actual paths whenever possible to avoid problems if the specific paths to any of these change. Some of the environment variables you should have are:

  • $HOME: path to your home directory
  • $PATH: all directories searched for commands/applications
  • $SHELL: your current shell (bash, tcsh, csh, ksh)
  • $KRB5CCNAME: path to your Kerberos ticket

You can find more about environment variables here.

All environment variables begin with the dollar sign ($) and are all uppercase. They may be used on the command line or in any scripts in place of and in combination with hard-coded values:

$ ls $HOME

You may find the value of any environment variable by using the echo command:

$ echo $SHELL

You may list the values of all environment variables using the env command:

$ env

You may create or overwrite an environment variable using either export or setenv, depending on your shell:

  (for bash and sh)
$ export VARIABLE=value

  (for tcsh and csh)
% setenv VARIABLE value
Updated: 2017-02-24, 23:23