Bashrc guidelines
The file .bashrc, located in your home directory, is read-in and executed whenever a bash script or bash shell is started. The exception is for login shells, in which case .bash_profile is started. The default .bash_profile calls .bashrc so that many scinet users never need to edit .bash_profile (the main exception is setting the PS1 variable, which you need to do in .bash_profile).
This means in particular that the file .bashrc is read in
- when you log in
- when you run compute jobs
- when you run certain commands (such as mpirun, and python-script-called bash scripts).
- at the end of a job, when copying output and error files.
Guidelines
To avoid difficulties, you are advised to follow these guidelines in .bashrc and .bash_profile:
- Sourcing /etc/bashrc in .bashrc is required for various things to work on Trillium!
- Do not execute any commands that write to standard output, because that would breaks things like copying-out output files and scp. So for instance, no echo or module list.
- Do not load any modules in your .bashrc or .bash_profile (or if you must, only very commonly-used modules).
- If you're trying out different implementations or versions of a module (e.g. mpi), you should definitely not load them in your .bashrc or .bash_profile, but explicitly on the command line before compiling and once more explicitly in your job script.
Default .bashrc and .bash_profile on Trillium
The default startup scripts provided by SciNet for Trillium are as follows. Certain things - like sourcing ~/.bashrc in ~/.bash_profile and /etc/bashrc in ~/.bashrc are required for various Trillium routines to work!
.bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific environment
if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]; then
PATH="$HOME/.local/bin:$HOME/bin:$PATH"
fi
if [ "$CLUSTER" = teach ]; then
alias passwd='echo "Please use the SciNet portal to change passwords: https://portal.scinet.utoronto.ca/portaluserlogin"'
else
alias passwd='echo "Please use the Alliance CCDB portal to change passwords: https://ccdb.alliancecan.ca"'
fi
# Do not change the commands above! Customized functions and aliases can be entered below.
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias chmod='chmod -v'
alias more='/usr/bin/less'
alias df='/usr/bin/df -h'
.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# Do not change or remove the above lines!
# User specific environment and startup programs