How are Environment Modules used in the Linux CLSE?

  • Environment modules enable users to modify their Linux environment dynamically
  • Modules can be loaded or unloaded using command-line programs
  • The CAEN Lab Software Environment  (CLSE) for Linux uses modules to specify which version of a software application one wishes to run
    • For example one can use the module avail command to display all available modules, or
    • Use the module load modulefile command to load a module

Note: If you receive an error similar to "module: command not found" while trying to run the commands described below, try running /bin/csh before the command that was failing.


The Linux Environment Modules package is available on all computers running the CAEN Lab Software Environment (CLSE) for Linux. This enables students to change settings in their shell dynamically using the software modulefile that is pre-configured by CAEN. When one loads a modulefile, the shell will be configured with all variables needed by the application (e.g. PATH, CLASSPATH, MANPATH, or LD_LIBRARY_PATH).

To determine which software versions are available, use the module avail command. If additional arguments are not specified, the command will display a listing of all available modules, as in the example below:

$ module avail

---------------------------------- /usr/share/modulefiles ----------------------------------
   mpi/openmpi-x86_64    pmi/pmix-x86_64

---------------------------------- /usr/caen/misc/modules ----------------------------------
   R/3.6.1                              moose/23.06
   abaqus/2022                          nanotime/2017.06
   adams/2019.2                         nanotime/2018.06
   ads/2016u1.3                         nanotime/2019.12-SP4
   ads/2017u1.0                         nanotime/2021.06-SP1
...

The list of all modules available on a CAEN computer may be long. To refine a search, one may add an additional argument to specify the modules available for a specific application. For example, the command module avail gcc might produce this output:

$ module avail gcc

---------------------------------- /usr/caen/misc/modules ----------------------------------
   gcc/6.2.0    gcc/7.1.0    gcc/8.3.1 (D)    gcc/9.1.0    gcc/9.4.0    gcc/11.3.0

If a module has multiple versions, one of them will be marked (default), as can be seen in the example above for gcc/4.8.5. The default module version is what will be loaded without specifying any version number when running an application.

To load a specific module version, use the module load modulefile command. Your shell will be modified to use the specified modulefile version. For example, prior to loading the modulefile for gcc.7.1.0, typing the gcc command would have run the default version in /usr/bin. After loading the module, the user's PATH environment variable is modified such that the version of gcc in /usr/um/gcc-7.1.0 is run instead.

Before loading the CAEN gcc modulefile:

$ printenv PATH
/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/um/bin
$ which gcc
/usr/bin/gcc
$ gcc --version
gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-15)
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

After loading the modulefile:

$ module load gcc/11.3.0
$ printenv PATH
/usr/um/gcc-11.3.0/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/um/bin
$ which gcc
/usr/um/gcc-11.3.0/bin/gcc
$ gcc --version
gcc (GCC) 11.3.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

To restore your environment to its previous state, use the module unload modulefile command, or simply log out:

$ module unload gcc
$ printenv PATH
/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/um/bin
$ which gcc
/usr/bin/gcc

Read More About Environment Modules

For more information about the environment modules, commands, and usage, visit the Environment Modules open source project page or type man module or module --help at a command line.