Environment Variables

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:

~/.bashrc

Aliases can be stored in:

~/.bash_aliases

These files are hidden. To display hidden files in your home directory, run:

ls -a

Common Environment Variables

The following table lists several commonly used environment variables.

Environment Variable

Description

Environment Variable

Description

$HOME

Path to your home directory

$PATH

List of directories the system searches for executable programs

$LD_LIBRARY_PATH

List of directories searched for shared libraries

$HOSTNAME

Name of the current host machine


Viewing Environment Variables

To see all environment variables currently set in your session, run:

env

Example 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 $HOME

Example output:

/home/linkblue

Setting or Modifying Environment Variables

Environment variables can be set or modified using the export command.

Example:

export PATH=$PATH:/home/$USER

This example appends a directory to the existing PATH variable.

Center for Computational Sciences