“The Environment Modules package provides for the dynamic modification of a user’s environment via modulefiles.

Each modulefile contains the information needed to configure the shell for an application. Once the Modules package is initialized, the environment can be modified on a per-module basis using the module command which interprets modulefiles. Typically modulefiles instruct the module command to alter or set shell environment variables such as PATH, MANPATH, etc. modulefiles may be shared by many users on a system and users may have their own collection to supplement or replace the shared modulefiles.

Modules can be loaded and unloaded dynamically and atomically, in an clean fashion. All popular shells are supported, including bash, ksh, zsh, sh, csh, tcsh, as well as some scripting languages such as perl.

Modules are useful in managing different versions of applications. Modules can also be bundled into metamodules that will load an entire suite of different applications.” [1]

Initialize modules

As stated before the environment package can be used in several popular shells. Before you can use modules you must initialize it.

Try it out

Initialize modules for the bash shell:

# . /usr/modules/init/bash

Listing the available modules

You can use the module command to list the available modules on a system, load/unload, and show the modules that you currently have loaded. To list the available modules use the ‘avail’ option:

List all the modules available on a system (note that this list is not current):

benji@fortyfour ~ $ module avail

---------------------------------------------- /opt/modules/modulefiles ----------------------------------------------
R/2.15.3                          hmmer/4.0                         parsinsert/1.04(default)
R/3.0.2                           hyphy/2.1.2(default)              partitionfinder/1.1.1(default)
R/3.1.0(default)                  ima2/8.27.12(default)             paup/4.10(default)
arc/1.0                           infernal/1.0.2                    pcap/1.0
arc/1.1(default)                  infernal/1.1(default)             perl/5.18.0(default)
arc-dev/1.0                       java/1.6.0                        phredphrap/0.990329(default)
arc-dev/1.1(default)              java/1.7.0(default)               phylip/3.695(default)
avida/2.12.4(default)             jmodeltest/2.1.3                  phyml/3.0(default)
beast/1.7.5                       jmodeltest/2.1.4(default)         phyml/3.0-20120412
beast/1.8.0(default)              lamarc/2.1.8(default)             phyml/dev
blat/35(default)                  libncl/2.1.18(default)            pplacer/1.1
blat-fastq/35(default)            mafft/7.046                       prank/1.0(default)
boost/1.55.0                      mafft/7.050                       prokka/1.10(default)
bowtie2/2.1.0(default)            mafft/7.130(default)              prokka/1.9
cap3/2013-08-06(default)          migrate/3.6(default)              prottest/3.4-20140123(default)
cdbtools/1.0(default)             mlcoalsim/1.42(default)           python/2.7.3
cdhit/4.5.4                       mothur/1.25.0                     python/2.7.5(default)
cdhit/4.6.1(default)              mothur/1.30.2(default)            python/3.3.2
chimeraslayer/2010-04-29(default) mrbayes/3.2.1(default)            qiime/1.8.0(default)
clann/3.2.3(default)              mummer/3.23(default)              raxml/7.2.8
clearcut/1.0.9(default)           muscle/3.8.31(default)            raxml/7.3.0
clustalo/1.2.0(default)           ncbi/2.2.28                       raxml/8.0.4(default)
clustalw/2.1(default)             ncbi-blast/2.2.28(default)        rdp_classifier/2.2(default)
cmake/           ncbi-blast-legacy/2.2.22(default) repeatmasker/4.0.3
cufflinks/2.1.1(default)          ncbi-c-toolkit/20120212(default)  repeatmasker/4.0.5(default)
dotur/1.53(default)               ncbi-toolkit/12_0_0               roche454/2.6
emboss/6.5.7(default)             ncl/2.1.18(default)               roche454/2.8
faststructure/1.0(default)        omssa/2.1.9                       roche454/2.9(default)
fasttree/2.1.3                    openmpi/1.6.4                     rtax/0.984(default)
fasttree/2.1.7(default)           openmpi-apps/1.6.4/abyss/1.3.6    stacks/1.12
fastx/           openmpi-apps/1.6.4/blast/1.6.0    stacks/1.20(default)
fiji/1.0(default)                 openmpi-apps/1.6.4/clustalw/0.13  structure/2.3.4(default)
flash/1.2.9(default)              openmpi-apps/1.6.4/examl/2.04     tax2tree/1.0
fusionq/0.5(default)              openmpi-apps/1.6.4/garli/2.01     tbl2asn/1.44(default)
garli/2.01(default)               openmpi-apps/1.6.4/gromacs/4.6.3  treemix/1.12(default)
gcc/4.3.3(default)                openmpi-apps/1.6.4/migrate/3.6    treepl/1.0(default)
grc/1.0(default)                  openmpi-apps/1.6.4/mothur/1.30.2  trf/4.07b(default)
grc/2.0                           openmpi-apps/1.6.4/mrbayes/3.2.1  uclust/1.2.22(default)
gsl/1.16(default)                 openmpi-apps/1.6.4/raxml/7.7.6    usearch/5.2.236(default)
hmmer/3.0                         openmpi-apps/1.6.4/raxml/8.0.5    velvet/1.1(default)
hmmer/3.1                         paml/4.7(default)
hmmer/3.1b1(default)              parallel/20131022(default)

Show what a module is

To see what a specific module is use the whatis command with modules.

benji@fortyfour ~ $ module whatis ncbi
ncbi                 : Adds both the ncbi-blast and ncbi-c-toolkit to your environment
ncbi                 : NCBI BLAST is a search tool for genetic sequences

Show the variables that a module sets

You can get a list of all the environment manipulations that a specific module sets, including the actual paths.

benji@fortyfour ~ $ module show ncbi

module-whatis    Adds both the ncbi-blast and ncbi-c-toolkit to your environment 
module-whatis    NCBI BLAST is a search tool for genetic sequences 
module       load ncbi-c-toolkit 
module       load ncbi-blast 

List out the modules you have loaded

To obtain a list of the modules you have loaded use the ‘list’ command.

benji@fortyfour ~ $ module list
No Modulefiles Currently Loaded.
benji@fortyfour ~ $ module load R
benji@fortyfour ~ $ module list
Currently Loaded Modulefiles:
  1) R/3.1.0

Load an environment module

Loading a module to customize your environment is easy using the load command.

Load the python module:

benji@fortyfour ~ $ module load python
benji@fortyfour ~ $ module list
Currently Loaded Modulefiles:
  1) R/3.1.0        2) python/2.7.5

Unload a module

To remove a module from your environment use the ‘unload’ command

Unload the R module:

benji@fortyfour ~ $ module unload R
benji@fortyfour ~ $ module list
Currently Loaded Modulefiles:
  1) python/2.7.5

To unload all modules, use the purge command

benji@fortyfour ~ $ module purge
benji@fortyfour ~ $ module list
No Modulefiles Currently Loaded.