Archive for the ‘Basic UNIX tutorials’ Category

Environment variables are place holders where UNIX keeps important information. Programs such as FSL and Freesurfer use them extensively as they are very configurable and have endless uses. They are usually store as capital letters with a “$” attached to their front. For example, if you want to see what the “$FSL_DIR” variable holds, just type:

echo $FSL_DIR

This should show you what is in the variable. If it returns an error message, or an empty line, it is not defined! Not to worry though, as it is fairly simple to change them. How you change them, depends on which “shell” you are working in. So how do you find this out? Type:

echo “$SHELL”

It should return something like:


The rest of this tutorial assumes you are using the “bash” shell. Most of the information your bash shell needs to work, is contained in the .profile script in your home directory. To tell Freesurfer and FSL where they are going to work, add the following to your .profile by typing:

Here is how to install fsl and freesurfer into your own home directory:

cp -vr /SCRATCH4/cubic/freesurfer-Linux-centos4_x86_64-stable-pub-v4.5.0-full.tar.gz /SCRATCH4/cubic/YOURUSERNAME
tar vxfz freesurfer-Linux-centos4_x86_64-stable-pub-v4.5.0-full.tar.gz
cp -vr /SCRATCH4/cubic/fsl-Linux-ubuntu_x86_64-CHPC.tar.gz .
tar vxfz fsl-Linux-ubuntu_x86_64-CHPC.tar.gz

emacs ~/.profile

Now copy/paste the following into the emacs window at the end of the file using either Ctrl-C Ctrl-V or highlighting the text and pressing the middle mouse button.

Remember to replace YOURUSERNAME with your own username!

source ${FSLDIR}/etc/fslconf/


To save in emacs, press Ctrl-X Ctrl-S, then to exit press Ctrl-X Ctrl-C.

To make your life easier, should you choose to use emacs as your editor, at these lines to the .emacs file by typing:

emacs ~/.emacs

… and paste the following at the end of the file:

(setq-default auto-fill-function ‘do-auto-fill)
(global-font-lock-mode 1)

To check if you have done everything correctly, type:
. ~/.profile
The following should appear on your screen:

——– freesurfer-Linux-centos4_x86_64-stable-pub-v4.5.0 ——–
Setting up environment for FreeSurfer/FS-FAST (and FSL)
FSFAST_HOME /SCRATCH4/cubic/YOURUSERNAME/freesurfer/fsfast
SUBJECTS_DIR /SCRATCH4/cubic/YOURUSERNAME/freesurfer/subjects
MNI_DIR /SCRATCH4/cubic/YOURUSERNAME/freesurfer/mni

There are two standard ways that data can be uploaded to CHPC. Firstly using the command line, and secondly using a GUI (Graphical Users Interface.) The GUI method will be explained here.

Very Important Note:
It is very important that you never give you password to anyone. Rather let them apply for their own login, as this could compromise the security not only of your login, but the entire CUBIC group! Remember, the more usernames we have in the CUBIC group, the more funding we can apply for! This is beneficial for everyone.

SCP using a GUI in Windows
There are various tools available that can relieve the hassle of copying files over SSH. WinSCP and Bitvise Tunnler are two options for Windows. Here is a tutorial explaining how to use WinSCP in detail. For host, use Set the port to 22 .

SCP using a GUI in Linux
Under Linux, secpanel can be used.

Here is a screenshot of how I setup my connection:

Here are some links I have found helpful in getting on the move with UNIX/Linux. Always remember if you want to do something, try googling it first. You will be able to learn just about anything Unix related if you just ask google.

Here are some links to get you started (I will be adding to this list in the coming months:

Beginner’s UNIX tutorial
Easy Shell Scripting
UNIX History on Wikipedia
Introduction to BASH programming