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 Niagara!
- 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 Niagara
The default startup scripts provided by SciNet for Niagara are as follows. Certain things - like sourcing ~/.bashrc in ~/.bash_profile and /etc/bashrc in ~/.bashrc are required for various Niagara routines to work!
.bashrc
if [ -f /etc/bashrc ]; then . /etc/bashrc fi function sbatch() { command sbatch --export=NONE "$@" } export -f sbatch alias passwd='echo "Please use the CCDB web portal to change passwords: https://ccdb.computecanada.ca"' # 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 -a -tgpfs -trootfs -h'
.bash_profile
if [ -f ~/.bashrc ]; then . ~/.bashrc fi # Do not change or remove the above lines. # Additional variables and path settings can be set below. export PS1='\u@\h:\w\$ '