In order to handle the many different software packages that are available here at ICS, we use a system called Modules. The Modules package is a system that will allow you to easily set your shell environment by selecting from different software packages.
Contents
- Introduction
- The Basics of the Modules System
- Useful Module Commands
- More Information about Modules
- Using Modules Well
- Getting Additional Information
Introduction
Modules is a system for configuring and maintaining the shell and environment variables needed to use various software packages. The Modules system is easy to use, has a built-in help facility, and runs on many platforms under many operating system versions.
Most importantly, Modules insulates you from the petty details of a package's installation. To use a software package, you usually have to add to your PATH and MANPATH variables, and you often have to set other application-specific or system variables as well. The Modules system frees you from having to know the precise pathnames to the various pieces of the package; what variables need to be set for the package to work; and from having to spend time tracking changes to all of this information.
The Basics of the Modules System
The following lines contain the minimum code required in your .cshrc. Note that these lines should be the very first statements executed in the .cshrc. This assures a well-configured environment for commands run later in your .cshrc, as well as for later interactive sessions. A complete example of a .cshrc file can be found in /opt/local/etc/skel/acct/cshrc.
# .cshrc
# Modules commands come first, to guarantee a
# well-configured environment for other commands
# source /opt/Modules/init/csh
module load ics-default
Every time you login, these commands are automatically executed and your environment is set up.
Useful Module Commands
- module avail
- Lists all of the modules available at ICS. (Note: some of these may not be available on your particular system).
- module display modulename
- Prints out a short description of the modulename, including the changes to your environment.
- module show modulename
- Shows information about modulename. It's similar to the module display command.
- module help modulename
- Shows you where you can get help and report bugs with the software in the module.
- module list
- Displays the list of modules that you have currently loaded.
- module load modulename
- Loads the current default version for the software package modulename. If you need to use a different version, then run module load modulename/version.
- module unload modulename
- Removes the specified module package from your shell environment.
- module initadd modulename
- Updates your .cshrc file by adding a module load line for the specified module.
- module initrm modulename
- Updates your .cshrc file by removing the specified module from the module load line.
More Information about Modules
- The ics-default module loads several commonly use modules, such as openssh, tex, x11, etc....
- You can add software packages to your environment by using the module load command, either interactively at the shell prompt or by adding the command to your .cshrc. If you run the command interactively, it will affect your environment in that window for the current session only. If you wish the change to be permanent, you will need to add it to your .cshrc. If you are adding it to your .cshr, you can either combine commands onto one line, or you can use a separate command line for each package.
- source /opt/Modules/init/csh
module load ics-default www sun-lang
- source /opt/Modules/init/csh
module load ics-default
module load www
module load sun-lang
- Following a few simple rules will let you personalize your environment safely:
- Modules commands should come before any direct setting of shell or environment variables.
- If you must assign a value to a variable that module modifies (e.g. PATH, and MANPATH) make sure to include the current value of that variable. For example to modify your path, you should do the following:
set path = (~/bin $path . )
This adds your "~/bin'' directory and ".'' (the current directory), to your path while keeping the existing entries. Don't forget that having ".'' in your path may create the risk of running a Trojan horse; if you cannot omit it entirely, make sure to make it the last item in your path.
Using Modules Well
It is possible to make every command you will ever want to run available all the time, by loading all of the modules. This may seem desirable at first, but it does have some drawbacks.
- Your environment is needlessly bloated with packages you rarely use. The negative effects of this are particularly noticeable when the man command has to search a long MANPATH.
- The time that it takes to login is increased, since the system has to configure everything for each module you load.
- Some packages may be mutually incompatible, or have undesireable interactions. For example, it is difficult to run some OpenWindows and MIT X11R6 programs from the same environment since they each require different settings for the LD_LIBRARY_PATH environment variable.
Fortunately Modules provides a way out of this dilemma. The
moduleruncommand allows you to specify an environment for just one command, without affecting the shell environment. For example, on SunOS 4.1.X, it is possible to not load the GNU package in your environment, but still be able to run ghostview. This is done using the following command:
modulerun gnu ghostview file.psEvery shell you start (or window you open), executes your
.cshrcfile in order to load thePATH,MANPATH, and other needed variables. Running themodule loadcommand in a shell window only affects that shell. Themoduleruncommand runs a subshell which does not affect the shell from which the command is run. Using a combination of these three can give you a rich and flexible environment with a minimum of wasted overhead.
Additional Information
Running the command
module helplists the options of the Modules system.There are UNIX man pages for Modules (
man module), and formodulerun. There is also a man page (man modulefile) with information on writing your own module file.The author of Modules is John L. Furlani of SunSoft. He presented a paper, Modules: Providing a Flexible User Environment, at the USENIX LISA V conference held in San Diego, October 1991. The paper is available in the proceedings from that conference.