Important .bashrc guidelines

From oldwiki.scinet.utoronto.ca
Revision as of 15:52, 24 June 2010 by Rzon (talk | contribs) (Created page with 'The file <tt>.bashrc</tt>, 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 ca…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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.

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
  • at the end of a job, when copying output and error files.

And that both on the GPS and the TCS, which nonetheless often require quite a different setup.

Guidelines

To avoid difficulties, you are advised to follow these guidelines in .bashrc:

  • Sourcing /etc/profile and /etc/bashrc is required for various SciNet routines to work!
  • 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.
  • Load only commonly used modules.
  • Distinguish, especially for the module command, between the gpc and tcs.
  • If you're trying out different implementations or versions of a module (e.g. intelmpi), you should not load them in the .bashrc, but explicitly on the command line before compiling and once more explicitly in your job script.

Default .bashrc/.bash_profile

The default startup scripts provided by SciNet are as follows. Certain things - like sourcing /etc/profile and /etc/bashrc are required for various SciNet routines to work!

.bash_profile <source lang="bash"> if [ -f /etc/profile ]; then

      . /etc/profile

fi

  1. commands which work for both GPC and TCS can go here

alias passwd='echo "Please use the SciNet portal to change password: https://portal.scinet.utoronto.ca/change_password"'

HOST=$(uname)

if [ "${HOST}" == "AIX" ] then

       # do things for the TCS machine
       alias llq1='/xcat/tools/tcs-scripts/LL/jobState.sh'
       alias llstat='/xcat/tools/tcs-scripts/LL/jobSummary.sh'
       if [ "${TERM}" = "xterm-color" ]; then
               export TERM=xterm
       fi
       # user environment for login shells goes here
       # replace colon with your own commands
       :

else

       # do things for the GPC machine
       # user environment for login shells goes here
       # replace colon with your own commands
       :

fi

PS1="\h-\$ "


if [ -f ~/.bashrc ]; then

      . ~/.bashrc

fi </source>

.bashrc <source lang="bash"> if [ -f /etc/bashrc ]; then

      . /etc/bashrc

fi

  1. commands which work for both GPC and TCS can go here

export BASH_ENV=~/.bashrc

HOST=$(uname)

if [ "${HOST}" == "AIX" ]; then

       # do things for the TCS machine
       # user environment for all shells goes here
       # replace colon with your own commands
       :

else

       # do things for the GPC machine
       module load intel openmpi
       # user environment for all shells goes here
       # replace colon with your own commands
       :

fi </source>