Bash Config File Example
Every time you log into the cluster or submit a job the commands in your $HOME/.bashrc
file will be executed. Here are some examples of changes that you can make to your $HOME/.bashrc
file using a text editor so that your environment is automatically configured when a new shell is opened.
Adding module commands to your .bashrc
As can be seen on the modules page the majority of software on one of Vikram-100 is not available until the module
command is used to load the software. By adding the relevant snippets to the .bashrc
you can automatically load certain modules each time a new session is opened.
The first snippet clears any modules that may be globally loaded:
# Clear any modules that may have been globally set module purge
Adding environment variables to your .bashrc
Loading software via the module command changes the PATH and LIBRARY variables but you can also make changes to these variables yourself.
The first snippet shows how you can add a directory such as $HOME/bin
to your $PATH
so that you can put commands and scripts there to run them more easily.
# Add $HOME/bin to your $PATH to make your commands easier to run. PATH=$PATH:$HOME/bin
The next snippet shows how you can change the LD_LIBRARY_PATH
so that your local library directory such as $HOME/MyLibrary
is included in the library search path.
# Add $HOME/MyLibrary directory to $LD_LIBRARY_PATH environment variable. LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/MyLibrary
With both the PATH
and LD_LIBRARY_PATH
the order of the directories is the order that they are searched in. If you have want to make sure that the library in your $HOME/MyLibrary
is loaded instead of a library of the same name elsewhere then the following snippet shows how
# Add $HOME/MyLibrary directory to $LD_LIBRARY_PATH environment variable. LD_LIBRARY_PATH=$HOME/MyLibrary:$LD_LIBRARY_PATH
You can also create your own environment variables such as $MY_VARIABLE
which you can then use in your commands and scripts. For example
# Create a new variable $MY_VARIABLE so that it is available for later use. export MY_VARIABLE=$HOME/code/example