Module Commands

The below table shows some useful module commands in discovery.

Commands Syntax Description

module avail

module avail

Shows all the available modules

module spider

module spider <software-name>

Retrieves the specific module

module load

module load <software-name>

Loads the specific module to your environment

module list

module list

Lists all the loaded modules

module swap

module swap <m1> <m2>

Unloads module m1 and loads module m2

module unload

module unload <software-name>

Gets rid of the specific module

module purge

module purge

Removes all the currently loaded modules

module reset

module reset

unload all currently loaded modules, including the sticky ones, and reload default ones

module help

module help

Prints the help information.

Module Avail

To view the list of available modules in discovery, run the following command.

Syntax: module avail

 module avail

Output

-------------------------------------------------------------- /fs1/software/sstack/rhel_8/modules ---------------------------------------------------------------
   conda/2022a    conda/2023a (D)    custom/2022a    custom/2023a    custom/2024a (D)    spack/2022a    spack/2023a (D)    sstack/main

------------------------------------------------------------------------ /etc/modulefiles ------------------------------------------------------------------------
   pmix/2.2.5    pmix/3.2.3    pmix/4.1.2 (D)

------------------------------------------------------------------ /fs1/software/sstack/modules ------------------------------------------------------------------
   os/centos_7_test (S)    os/centos_7 (S)    os/rhel_8_test (S)    os/rhel_8 (S,L,D)

------------------------------------------------------------- /usr/share/lmod/lmod/modulefiles/Core --------------------------------------------------------------
   lmod    settarg

  Where:
   S:  Module is Sticky, requires --force to unload or purge
   L:  Module is loaded
   D:  Default Module

If the avail list is too long consider trying:

"module --default avail" or "ml -d av" to just list the default modules.
"module overview" or "ml ov" to display the number of modules for each name.

Use "module spider" to find all possible modules and extensions.
Use "module keyword key1 key2 ..." to search for all possible modules matching any of the "keys".

The above output shows the current viewable list of the available modules. It doesn’t show or search the entire modules tree.

Use module spider command to be able to search the entire tree of modules.

Module Spider

Module spider can be used to search for any specific module. For example, if you want to search for any particular module like R and only its associated versions, use the below command

Syntax: module spider <software-name>

$ module spider r
  r:
--------------------------------------------------------------------------------------------------------------------------------------------------------------
     Versions:
        r/4.1.2-RStudio_Server_2022.02.2.485-SIF
        r/4.1.3-RStudio_Server_2022.02.2.485-SIF
        r/4.2.0-RStudio_Server_2022.02.2.485-SIF
        r/4.2.0-2022a-gcc_12.1.0-dcz3bjq
        r/4.2.0-2022a-gcc_12.1.0-dd4egyh
        r/4.2.2-2023a-gcc_12.2.0-oagyew6
        r/4.2.3-RStudio_Server-VSCode-Jupyter-SIF
        r/4.3.2-RStudio_Server-VSCode-Jupyter-SIF
     Other possible modules matches:
        argobots  autoconf-archive  berkeley-db  ca-certificates-mozilla  cairo  code-server  curl  double-conversion  fontsproto  freetype  freexl  fribidi  ...

--------------------------------------------------------------------------------------------------------------------------------------------------------------
  To find other possible module matches execute:

      $ module -r spider '.*r.*'

--------------------------------------------------------------------------------------------------------------------------------------------------------------
  For detailed information about a specific "r" package (including how to load the modules) use the module's full name.
  Note that names that have a trailing (E) are extensions provided by other modules.
  For example:

     $ module spider r/4.3.2-RStudio_Server-VSCode-Jupyter-SIF
--------------------------------------------------------------------------------------------------------------------------------------------------------------

Syntax:: module spider <full-module-name>

$ module spider r/4.2.0-RStudio_Server_2022.02.2.485-SIF
   r: r/4.2.0-RStudio_Server_2022.02.2.485-SIF

      You will need to load all module(s) on any one of the lines below before the "r/4.2.0-RStudio_Server_2022.02.2.485-SIF" module is available to load.

      custom/2022a

      Help:
         For help contact your site administrators.

It displays the modules associated with the different versions of R and now you can load the appropriate version by loading the prerequisite modules first.

Module Load

To load a specific version of the perl from the list of available modules, you can do it by running the module load command. The syntax for the module load command is the following.

Syntax: module load <software-name>

module load conda/2022a

You can also load several modules by typing the module names one by one in a single line. Run the below single-line command to load multiple modules.

Syntax: module load <sofware-name1>…​<software-n>

Press the tab key in your keyboard to complete the software names and versions. The names sometimes contain special characters, spaces and rather than typing the complicated filename, you can start typing the beginning of the name, and then hit tab key afterward.

Module List

The module list command helps to list all the currently loaded modules in your environment.

Syntax: module list

module list

Output:

Currently Loaded Modules:
1) perl/5.30.0-gcc-9.2.0-h7kut76   2) julia/1.4.2-gcc-9.2.0-ncvp5em   3) ruby/2.6.2-gcc-9.2.0-vbzxuyf

The output shows the list of currently loaded modules.

Module Unload

To remove a specific module which you no longer need or you want to discard it, run the below command.

Syntax: module unload <software-name>

module unload perl

Output:

Currently Loaded Modules:
1) ruby/2.6.2-gcc-9.2.0-vbzxuyf   2) mpi/openmpi-x86_64

Module perl has been successfully removed from your environment.

You have to run the module list command after the unload command to view the list of the currently loaded modules.

Module Reset

The module reset command is used to unload all currently loaded modules and then reload all default modules that are supposed to be loaded at login. This can be particularly useful for clearing any changes you’ve made during the session and returning to the default state.

To unload all currently loaded modules and then reload all default modules, run:

module reset

Module Purge

If you want to get rid of all the loaded modules in your environment, use the below command

Syntax: module purge

module purge

Output:

No modules loaded

The above output after running the module purge and list command shows that all the loaded modules have been removed from the environment successfully.

Note that Module unload is used to remove a specific module from your environment and module purge is used to get rid of all the modules.

Module Help

This command helps to explore all the options, commands and arguments associated with the module command.

Syntax: module help

module help

Output:

Usage: module [options] sub-command [args ...]

Options:
-h -? -H --help                   This help message
-s availStyle --style=availStyle  Site controlled avail style: system (default: system)
--regression_testing              Lmod regression testing
-D                                Program tracing written to stderr
--debug=dbglvl                    Program tracing written to stderr (where dbglvl is a number 1,2,3)
--pin_versions=pinVersions        When doing a restore use specified version, do not follow defaults
-d --default                      List default modules only when used with avail
-q --quiet                        Do not print out warnings
--expert                          Expert mode
-t --terse                        Write out in machine readable format for commands: list, avail, spider, savelist
--initial_load                    loading Lmod for first time in a user shell
--latest                          Load latest (ignore default)
--ignore_cache                    Treat the cache file(s) as out-of-date
--novice                          Turn off expert and quiet flag
--raw                             Print modulefile in raw output when used with show
-w twidth --width=twidth          Use this as max term width
...
...
...