BASH Customisation (New cluster)
How to customise your terminal sessions on WIN servers.
Introduction
The web is full of suggestions on how to make terminal sessions more productive; software packages request you make changes to your environment; you see a fancy prompt on someone else's terminal and want yours to behave the same - this page describes how to do that without breaking the system presets.
These instructions only apply to the centrally managed interactive Linux servers (clint.fmrib.ox.ac.uk, clcpu01.cluster.fmrib.ox.ac.uk etc) - desktop computers (Linux/macOS) do not necessarily use the mechanisms below (or indeed use BASH at all).
We strongly recommend that you do not automatically activate any Conda Python environments in your profile, it is known to break VNC startup.
Configuration files
The shell you use on FMRIB computers is called BASH, it is setup through two files, .bash_profile and .bashrc which may contain the same types of configuration. The former is run when you log into a computer, usually via SSH, the later when you open a Linux terminal not configured as a login shell or when you run a command on a remote computer over an SSH connection.
For example, ssh clint.fmrib.ox.ac.uk will result in .bash_profile being loaded (or sourced) whereas ssh clint.fmrib.ox.ac.uk date will result in .bashrc being loaded, the date printed and you returning to your computer.
.bash_profile
The .bash_profile is where we configure the system defaults, e.g. where to find software, what their settings are etc. You should take care with what you put in this file so as to not prevent these defaults from loaded.
By default, a new account's .bash_profile contains very little as most software setup is handled through the loading of environment modules.
Make sure you make a backup of your current .bash_profile if you have modifications you want to re-apply to the new profile.
Cluster defaults are loaded at the start of the file, do not change this section. After that feel free to modify the settings, but if you are at all unsure of what you are doing please contact the WIN IT team for advice. If you are missing the following:
if [ -f ~/.bashrc ]; then . ~/.bashrc fi
Then add this before the section:
if [ "X$SHELL" != "X$CURSHELL" ]; then
exec $SHELL
fi
at the end of the file.
The latest version of this file adds a section that will load settings from a file ~/.local_profile, so if you have this version feel free to create this file and modify the settings there.
.bashrc
We recommend you use this file for setting up aliases.
Do not 'echo' any output in your .bashrc, this will break 'scp' commands. If you wish to run a command or source a setup script that outputs text either send the output to /dev/null or consider ensuring that this does not run when in a non-interactive session.
- Redirecting output:
-
module add freesurfer/current > /dev/null
-
- Prevent from non-interactive sessions
-
if [ -n "$SSH_TTY" ]; then echo "Hello"; fi
-