Skip to content

Note

bash is the only officially supported shell for the HPCC. For information about running shell scripts written for other shells (zsh, csh, etc) or using an alternative shell, see this Lab Notebook.

Linux shells

A Unix/Linux shell is a command-line interpreter which provides a user interface for the Unix/Linux operating system. Users control the operation of a computer by submitting single commands or by submitting one or more commands via a shell script.

The default shell provided to HPCC users is the bash shell.

To find out your current shell run echo $SHELL.

Environment variables

Environment variables are a set of dynamically named values which can control the way running processes will behave on a computer. Many of the Unix commands and tools require certain environment variables to be set. Many of these are set automatically for the users when they log in or load applications via the module command.

To view your current set of environment variables run env.

To assign a new value to an environment variable in either bash: export <name>=<value>

To print the value of a variable: echo $<name>

Commonly used environment variables

Bash variables are preceded with $ and optionally enclosed in brackets when used e.g. $USER or ${USER}.

  • $HOSTNAME: Name of the computer currently running the shell or script. If used in a SLURM job, this should be one of the nodes listed in the variable $SLURM_JOB_NODELIST
  • $USER: User's name (NetID). Useful if you would like to dynamically generate a directory on some scratch space.
  • $HOME: User's home directory. Can also use ~/ symbol.
  • $SCRATCH: Your folder on the scratch disk.
  • $TMPDIR: Temporary working folder of a running job at /mnt/local/$SLURM_JOBID.

To see all variables in the context of your job, add this line to your job script, which will list all variables that contain the word 'SLURM'

1
$ env | grep SLURM