Environment Variables
Environment variables are dynamic values that influence the behavior of processes and applications on a computer. They configure system settings, manage paths to executable files and libraries, and store user-specific information such as home directories and shell preferences.
Users can customize their operating environment by setting or modifying environment variables in shell configuration files such as .bashrc or .bash_profile.
Initialize Your Environment
The LCC and MCC clusters use Bash as the default shell.
When a new shell session begins, Bash reads commands from the following configuration files:
~/.bash_profile~/.bashrc
Environment variables are typically defined in:
~/.bashrcAliases can be stored in:
~/.bash_aliasesThese files are hidden. To display hidden files in your home directory, run:
ls -aCommon Environment Variables
The following table lists several commonly used environment variables.
Environment Variable | Description |
|---|---|
| Path to your home directory |
| List of directories the system searches for executable programs |
| List of directories searched for shared libraries |
| Name of the current host machine |
Viewing Environment Variables
To see all environment variables currently set in your session, run:
envExample output:
[linkblue@login004 linkblue]$ env
MKLROOT=/opt/ohpc/pub/intel/compilers_and_libraries_2020.4.304/linux/mkl
HOSTNAME=login004
SHELL=/bin/bash
PROJECT=/project
HISTSIZE=1000
TERM=xterm
...Display the Value of a Variable
To display the value of a specific environment variable, use the echo command.
Example:
echo $HOMEExample output:
/home/linkblueSetting or Modifying Environment Variables
Environment variables can be set or modified using the export command.
Example:
export PATH=$PATH:/home/$USERThis example appends a directory to the existing PATH variable.