# Setup Lmod
1. Install the prerequisites for compiling [Lmod](https://github.com/TACC/Lmod) from source.
```bash
sudo apt install -y \
bc lua5.4 liblua5.4-dev lua-filesystem lua-json lua-posix lua-term tcl-dev
```
2. Download and extract the latest version of Lmod [source archive](https://github.com/TACC/Lmod/releases/latest). It is `8.7.60` at the time of writing.
```bash
export VERSION="8.7.60"
wget "https://github.com/TACC/Lmod/archive/refs/tags/${VERSION}.tar.gz" -O "Lmod-${VERSION}.tar.gz"
tar -xf "Lmod-${VERSION}.tar.gz"
```
3. Configure, compile and install Lmod.
```bash
mkdir -p "Lmod-${VERSION}-Build"
cd "Lmod-${VERSION}-Build"
"../Lmod-${VERSION}/configure" --prefix="/opt"
sudo make install
sudo mkdir -p "/etc/lmod"
```
4. Add to shell startup files.
```bash
sudo ln -fs "/opt/lmod/lmod/init/profile" "/etc/profile.d/z00_lmod.sh"
sudo ln -fs "/opt/lmod/lmod/init/cshrc" "/etc/profile.d/z00_lmod.csh"
```
5. Log out and log in again. Then, check if `module` works. For example,
```
module avail
---------------------------------------------------------------------------------------- /opt/lmod/lmod/modulefiles/Core ----------------------------------------------------------------------------------------
lmod settarg
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".
```