LearningUnix - MRC CBU Imaging Wiki
CbuImaging: LearningUnix

HELP WITH BASIC UNIX COMMANDS

Learning Unix

is not always easy for those of us who have grown up with Windows and the Macintosh. It's worth saying that once you are used to it, it is extremely powerful, and the other platforms can feel cumbersome by comparison. Anyway, enough propaganda.

There are a lot of guides to learning Unix on the web. Below are some links to a few of them. However, there is so much to Unix, that I have also made a list of Unix things we imagers often use. I suggest that you have a quick look at the list, and then try one of the tutorials. The list may be useful later on, for tips on things you might not have considered (such as archiving, killing dead processes etc).

Tip: If you have a problem, just try typing it (or the error message, if there is one) into Google, and there is a good chance you may find the answer. Clearly, the more specific you can make the words you use, the better Google will be able to find the answer. This advice applies to learning Linux, finding the nearest florist, a lack of libido, or all manner of other situations. Google is your friend.

Unix tutorials

So, maybe you would like to try one of the many good unix tutorials on the web. Here are a couple of links to start: * The CBU has some excellent commercial guides to Unix and its various utilities. CBU users should start at the CBU Unix support page (sorry, this page is not available outside the Unit).

Things we think you might want to know about Unix

Here is a list of the commands and concepts that we have found useful in learning Unix. We suggest these so that you will have some idea what to concentrate on if you go ahead and look at the unix tutorials. * It is essential to understand unix directory structure, and how paths work. Things you will come across are:

  • The concept of a file path, and the root directory
  • Forwardslashes to delineate directories on a path
  • The way that unix can make different types of storage device appear on same directory tree.
  • Finding where you are with "pwd"
  • Listing the files in a directory with "ls", and the options of the ls command, such as ls -l to give you file details, and ls -t to sort the files in time order.

  • Your home directory, where it is, how to use the tilde (~) to get to your home directory.
  • Making and removing directories, with "mkdir" and "rmdir"
  • File names in unix
    • Permissable file names, file name extensions
    • Moving, copying and removing files, with "mv", "cp", and "rm" respectively. Moving and copying entire directory trees with "mv -r", and "cp -r"
    • How file name wildcards work - "*", "?" etc.
  • Managing your disk space:
    • Archiving with "tar"
    • Compressing with gzip
    • Finding how much space is left with "quota -v" and "df"
    • Finding how much disk space files and directories are using with "du"
  • Security and permissions
    • Understanding file permission and directory flags, the output of "ls -l"
    • Changing permissions with "chmod"
  • Process control in unix
    • the concept of a process,
    • list processes with "ps"
    • killing processes with "kill"
    • tracking the rescources processes are using with "top"
  • Getting help within unix
    • the "man" command, for showing manual pages on unix commands
    • the "apropos" command
    • tkman - graphical interface to the man pages. For example, try typing "tkman ls" for help on the "ls" command
    • the online HTML help on the Sun systems
  • Editing text in unix
    • textedit on the Suns
    • emacs, wonderful, but steep learning curve
    • nedit - a simple graphical text editor, based on Windows/Mac editors
    • only the heavy techie uses "vi".
  • Looking at the contents of text files, with "cat", "more" or "less", "head", and "tail"
  • Using the c-shell and tc-shell, including the history commands, such as "!" and "!!"
  • How to get files from remote machines, using ftp

Some first tips

In general: don't forget to be careful of case and of spaces in typing commands and file names. Remember that unix, unlike MSDOS and Windows, cares about UPPER and lower case.Consider using emacs as your text editor. It has a load of useful features, will show you directory listings in a useful format, has special features for editing matlab and c programs, and is an excellent way to get to the unix "man" help pages.

Unix and SPM

There is little that you need to know about unix that is specific to SPM. The one key thing is the way that SPM stores its analyses. SPM stores all its analysis files in the current directory. This is, by default, the directory from which you start matlab, or, at the CBU, the directory from which you start SPM (at the CBU we have an automatic SPM and then matlab startup script - see the SPM versions page ). This directory will contain the postscript file containing the results printouts, and the analysis files, from the statistics. If you start SPM in a directory which has analysis files in it, the analysis files may be overwritten. So, to save a new analysis without losing the old analysis, make a new directory, or change to a directory where you want the results files, and start SPM from there. Alternatively, you can use the SPM "Utils" button, and the "CD" option there, to change directory after you have started SPM. Warning: don't change directory within matlab/SPM, using the "cd" command in the matlab window; it may not work as expected.

MatthewBrett 11/10/99

CbuImaging: LearningUnix (last edited 2013-03-07 21:24:06 by localhost)