Computing Environment

Status
Yes

Unix Shell

The Unix Shell interprets the text on each command entered by the user and the lines of statements in a shell script. To determine your shell, type:

echo $SHELL

Using the chsh command, you can change your shell. To check available shells, type:

chsh -l

To change your shell to bash (for example), type

chsh -s /bin/bash

Environment Variables

Many of the Unix commands and tools look in the environment for variables that specify information they may need to access. For example, if you want to run Matlab, simply typing matlab on the terminal will launch Matlab if the executable matlab is located in your environment. To see what is in your environment, type:

env

The variables are listed as keyword/value pairs separated by an equal (=) sign, as illustrated below by the $HOME and $PATH variables.

HOME=/home/user

PATH=/home/user/anaconda/bin:/opt/openmpi-1.6.4/bin/:/sw/bin

Notice that the $PATH variable consists of several entries that are separated by colons (:). In the above example, if matlab executable is included in any of the folders in $PATH, then typing matlab will launch it. In this case, matlab can be found under /sw/bin, so typing matlab will work.

Startup Scripts

Unix shells allow the user to customize their environment via startup files containing scripts. These startup scripts are located in your home directory. For bash, the name if the file that has the script is .bashrc, and for csh it is .cshrc. By entering commands in your startup shell, you can change what is in your environment when you login to the system. For example in .bashrc

export PATH="/home/user/anaconda/bin:$PATH"

will include the folder /home/user/anaconda/bin in the top of your $PATH. The executables in this folder can be called directly from the terminal.

export PATH=/opt/openmpi-1.6.4/bin/:$PATH
export LD_LIBRARY_PATH=/opt/openmpi-1.6.4/lib:$LD_LIBRARY_PATH

The first one will add commands like mpirun in your $PATH and the second one will add mpi libraries in your library path so that compiling with mpicc, mpif90 etc. will link to the right libraries.