Access to many applications and libraries is controlled by the modules utility. The module command allows you to easily manipulate your Linux environment to use various applications and programming libraries, sometimes including older or newer versions than the default. When you need to change your environment you simply load or unload modules. Here a some of the commands you’ll need.

List the software that’s available via the module command:

[username@linuxremote1 ~]$ module avail

----------------------- /usr/remote/etc/modulefiles -------------------------
adina/8.9.2                 last/737(default)
adina/9.0.4(default)        mathematica/10.1.0(default)
augustus/3.2.2(default)     matlab/R2015a(default)
bamtools/2.4.0(default)     ncbi-blast+/2.2.31(default)
BUSCO/1.1b1(default)        node/4.1.1(default)
comsol/5.0(default)         null
crb-blast/0.6.6(default)    python/2.7
dammit/0.2.8(default)       python/3.2(default)
EMBOSS/6.5.7(default)       python/3.4
gcc/4.8(default)            ruby/2.3.0(default)
hmmer/3.1b2(default)        TransDecoder/2.1.0(default)
infernal/1.1.1(default)

----------------------------- /etc/modulefiles ------------------------------
compat-openmpi-psm-x86_64   mpich-x86_64
compat-openmpi-x86_64       openmpi-x86_64

List the software that’s currently loaded in your environment (NOTE: some software is loaded by default when you login to a Bucknell Linux system):

[username@linuxremote1 ~]$ module list
Currently Loaded Modulefiles:
  1) python/3.2

Load/add a software package into your environment:

[username@linuxremote1 ~]$ module load matlab/R2015a

You can also load the default version of a software package by dropping the version:

[username@linuxremote1 ~]$ module load matlab

Unload/remove a software package from your environment:

[username@linuxremote1 ~]$ module unload matlab/R2015a

Modules will prevent you from adding conflicting packages. For example, you’ll receive an error if you try to add two versions of Python to your environment. To change to a new version, either unload one version and load another or use the switch command:

[username@linuxremote1 ~]$ module list
Currently Loaded Modulefiles:
  1) python/3.2
[username@linuxremote1 ~]$ module switch python/2.7

To add modules to your Linux environment that will load every time you login, use:
(NOTE: only run the echo command once; then just use initadd to add additional modules):

[username@linuxremote1 ~]$ echo "module add null" >> ~/.bashrc
[username@linuxremote1 ~]$ module initadd node/4.1.1

(NOTE: if you use the tcsh shell, you’ll need to run echo “module add null” >> ~/.cshrc)

Likewise, you can remove commands from your initial environment using:

[username@linuxremote1 ~]$ module initrm node/4.1.1

For additional commands, run:

[username@linuxremote1 ~]$ module help

For additional information or assistance, please contact the Tech Desk at 570.577.7777 or techdesk@bucknell.edu.

Keywords: linux, environment

Tagged: