Use bash

For these instructions to work, you'll need to make sure you're default shell is bash. You may be using ksh, tsh, or some other command line interface. To check, run

ps -p $$

and you should see something like

  PID TTY          TIME CMD
6453 pts/0    00:00:00 bash

The CMD column tells me I'm running bash, which is good.

If you're using a server at Iowa State, you can change your default login shell this way:

  1. Log into ASW (Account Services on the Web).
  2. Click "Manage Net-ID".
  3. Click "View/Edit your (Linux/Unix) login shell".
  4. Select /bin/bash from the dropdown menu.
  5. Click "Update Shell".
  6. Close all instances your shell on the server.

Other institutions should have something similar. Otherwise, there are several pages on changing shells, including this one.

Changing the default version of R

The global default version of R on our Linux servers is outdated. When I open Terminal, log into linux11, and open R, I see that I'm running version 2.14.1.

$ ssh [email protected] -p 323
$ R

R version 2.14.1 (2011-12-22)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-unknown-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

>

Personally, I would rather use version 2.15.3, which is stored in /apps/R-2.15.3/bin/ on linux11. I can open it manually with

$ /apps/R-2.15.3/bin/R

R version 2.15.3 (2013-03-01) -- "Security Blanket"
Copyright (C) 2013 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-unknown-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

>

But wouldn't it be nice to just type 'R' and get version 2.15.3 instead of 2.14.1? And what about Rscript? You can locally set both to version 2.15.3 with these steps.

  1. If you haven't done so already, open a command line interface program like Terminal and log into one of the Linux servers.

    $ ssh [YOUR_ISU_ID]@linux11.stat.iastate.edu -p 323
    

    Just one Linux server will do. The changes you make in the next steps will carry over to the rest of the Linux servers.


  2. Change to your home directory if you're not there already.

    $ cd ~
    
  3. Open your .bashrc file in a text editor.

    $ emacs .bashrc
    

    For those of you who don't know, emacs is an old but still popular text editor that can be called from a command line interface program. Vim and vi are alternatives.

    My .bashrc looks like this.

    # .bashrc
    
    # Source global definitions
    if [ -f /etc/bashrc ]; then
      . /etc/bashrc
    fi
    
    # User specific aliases and functions
    export PS1='`hostname` `echo \$PWD`> '
    export LD_LIBRARY_PATH=:/usr/local/cuda/lib64
    
    export PYTHONPATH=$HOME/.local/lib/python2.6/site-packages:$PYTHONPATH
    export PYTHONPATH=$HOME/.local/lib/python2.7/site-packages:$PYTHONPATH
    
    export PATH=$PATH:$HOME/.local/bin
    export PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
    export PATH=$PATH:$HOME/bin
    export PATH=$PATH:/apps/bin
    export PATH=$PATH:$HOME/packages/ImageMagick-6.8.6-0/bin
    export PATH=$PATH:/usr/local/cuda/binlinux11.stat.iastate.edu
    
  4. Locate the last appearance of "export PATH". Create a line below and insert

    export PATH=/apps/R-2.15.3/bin:$PATH
    

    For example, my .bashrc changes to

    # .bashrc
    
    # Source global definitions
    if [ -f /etc/bashrc ]; then
      . /etc/bashrc
    fi
    
    # User specific aliases and functions
    export PS1='`hostname` `echo \$PWD`> '
    export LD_LIBRARY_PATH=:/usr/local/cuda/lib64
    
    export PYTHONPATH=$HOME/.local/lib/python2.6/site-packages:$PYTHONPATH
    export PYTHONPATH=$HOME/.local/lib/python2.7/site-packages:$PYTHONPATH
    
    export PATH=$PATH:$HOME/.local/bin
    export PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
    export PATH=$PATH:$HOME/bin
    export PATH=$PATH:/apps/bin
    export PATH=$PATH:$HOME/packages/ImageMagick-6.8.6-0/bin
    export PATH=$PATH:/usr/local/cuda/binlinux11.stat.iastate.edu
    export PATH=/apps/R-2.15.3/bin:$PATH
    

    If the version of R you want to use were stored in [SOME_OTHER_FOLDER], you would instead insert

    export PATH=[SOME_OTHER_FOLDER]:$PATH
    
  5. Save your changes to .bashrc and exit the text editor. In emacs, you can do this by holding the control key and pressing x, then s, then x, then c.

  6. Log out of the Linux server and then log back in. Now, when you type in 'R' or 'Rscript', version 2.15.3 will automatically load.

    $ R
    
    R version 2.15.3 (2013-03-01) -- "Security Blanket"
    Copyright (C) 2013 The R Foundation for Statistical Computing
    ISBN 3-900051-07-0
    Platform: x86_64-unknown-linux-gnu (64-bit)
    
    R is free software and comes with ABSOLUTELY NO WARRANTY.
    You are welcome to redistribute it under certain conditions.
    Type 'license()' or 'licence()' for distribution details.
    
      Natural language support but running in an English locale
    
    R is a collaborative project with many contributors.
    Type 'contributors()' for more information and
    'citation()' on how to cite R or R packages in publications.
    
    Type 'demo()' for some demos, 'help()' for on-line help, or
    'help.start()' for an HTML browser interface to help.
    Type 'q()' to quit R.
    
    >
    

    You have just changed the local default versions of R and Rscript on linux10, linux11, and impact1 through impact4.

Locally setting the version of R is a practical solution for an individual. However, as a department, we should talk about

  1. the global version of R we want to use right now.
  2. how often we should update R.

The IT guys want to help us, but as they say, we haven't given them a clear consensus. My vote is to switch to version 2.15.3 now and then update every year, skipping problematic versions like 3.0.0. Feel free to discuss below.