Events News Research CBS CBS Publications Bioinformatics
Staff Contact About Internal CBS CBS Other

Pedestrian guide to UNIX



This guide introduces UNIX at a very basic level needed for the PhD course #27803. If you are already familiar with UNIX you only need to inspect the chapters Logging in, Printing and Getting help.

Index

Logging in from windows portable
Logging in from thin client
Xwindows
Using the WWW browser
Shell File system navigation
Simple file commands
Viewing and editing files
Printing
Manual pages
Getting help

Some exercises will be conducted on the Silicon Graphics servers at CBS, under IRIX 6.5 (UNIX). The servers will be accessed from portable computers (IBM ThinkPads), running Windows 2000 or thin client running Unix.

The course participants will form groups of two; each group has its own account on the system. The user names are:

    msc03, msc04, msc05, ...


Logging in from Windows portable

Logging in to the CBS servers is done as follows:
  • Start your portable computer. You will be logged in automatically as user 'student'; no password is required.

  • When the splash screen disappears, double-click on the 'SSH Secure Shell' icon (looks like a computer screen). A terminal window will appear.

  • Now you can click on 'Quick Connect' to connect to our server. The dialog box asks for a hostname which should be genome.cbs.dtu.dk (already there) and a username. That would be msc03, msc04 .......
    Write the username you have been given and press <enter> or click on 'Connect'.

  • You will be prompted for a password. You should have been informed of your password, so type the password. The password will not be echoed i.e. seen on the screen as you are typing it. That may seem confusing at first and lead to spelling mistakes. Do not try to correct them in blind; after having been denied access just try again.
  • Congratulations. You are now logged in.¬†You are now running a terminal window called a 'shell'.

  • Sometimes it is very nice to have more than one shell, e.g. you want to type commands from one shell, while keeping some results in another shell. On the tool bar (just below the menu bar) there is an icon, that looks like a minature of the 'SSH Secure Shell' icon. Click on that and you get a new shell popping up. Very useful.

  • You might even want to copy files from the Unix system to your portable. Next to the minature 'SSH Secure Shell' icon, there is a minature folder icon. Click on that, and a file transfer window pops up. Just use drag-and-drop from the desktop to the unix folder (or vice versa).


Logging in from thin client (Sun/UNIX)

First you need to log in to your DTU databar account;
Just type your userID (looks like s3233009) followed by your passwword.
Now you get a blank desktop, by middle-clicking on your mouse, you will get a menu, choose 'terminal' (the top choice). A submenu will appear and you choose any terminal, I personally like 'bohr'.
Now you connect to CBS servers by typing 'ssh -X msc04@genome.cbs.dtu.dk'. Remember to replace msc04 with YOUR CBS ACCOUNT.
The first time you do this you might get a message about being unable to verify the authenticity of the host, type type 'yes' (not 'y') and go on. Now you will be asked for your CBS password. That has already been given to you at the lecture. Congratulations, you are in.


Xwindows

The window system in the UNIX world (called 'X' or 'Xwindows') is quite similar to the PC Windows or Macintosh environments. Windows can be created/deleted, (de)iconized, scrolled, enlarged, moved etc. with the help of the mouse. Such operations will not be described here; after a few experiments you will manage to perform them.

It is possible to copy and paste fragments of text between (most) windows.
Note:  you will also need to copy and paste between Unix and applications running directly under Windows; in such cases follow the rules of the system you are in e.g. in Windows copy a text with Ctrl-C and paste it in the shell with Shift-Insert.


Using the WWW browser

The exercise manuals in this course are linked directly from the course programme. You should run a WWW browser to view them throughout the exercise. Start Internet Explorer on your portable under Windows and alternate between shell windows and the browser whenever needed (use Alt-Tab to toggle).


Shell

There is a special type of window called 'shell' or 'terminal window' that is similar to an MS-DOS window in Windows and lacks equivalent in the Macintosh environment. Terminal windows are the principal vehicle of interaction with a UNIX machine. Their function is to perform the commands typed into them.

An active terminal window will display a prompt and pause waiting for a command. The prompt can look like this:

genome[msc14]:/home/people/msc14/alignment>

It means that you have logged in to the machine called "genome", your username is "msc14" and you are in the directory (=folder) "alignment" in the directory "msc14" in the directory "people" in the directory "home" at the highest level of the file hierarchy.

The commands are submitted by typing them after the prompt and then hitting the RETURN key. They may be copied/pasted from another window (see above). The command you have typed is not submitted until you hit the RETURN key; you can move back and forth in the command string using the LEFT and RIGHT arrow keys and correct mistakes quietly. A command line may be longer than a line on the screen, just keep typing!

As soon as the RETURN key has been hit the execution starts. Do not be alarmed if nothing happens at once; sometimes it takes a while to load and activate a program.

If you are familiar with MS-DOS, please note these differences in UNIX:

  • Commands and file names are case-sensitive: X.AA and x.aa are two different files.
  • Directories in path names are delimited by / (slash), not \ (backslash).
  • There are no drive letters, such as C:.
  • Options to commands are normally preceded with a - (minus), not a / (slash).


File system navigation

The contents of the current directory (=folder) can be examined by typing 'ls' ("list"). It can look like this:
genome[msc14]:/home/people/msc14/alignment> ls
file1    file2 dir1 dir2
To get more information than just the file names, use 'ls -l' or the shorthand 'll' ("list long"). This gives you the permissions, ownership, size, and last modification time of all the files.

You can change to a directory in the current directory with the command 'cd':

genome[msc14]:/home/people/msc14/alignment> cd dir2
genome[msc14]:/home/people/msc14/alignment/dir2>
Notice the the prompt changes as you go to another directory.

To go up one level in the hierarchy, use 'cd ..'. To go to your home directory, use 'cd' with no arguments:

genome[msc14]:/home/people/msc14/alignment/dir2> cd ..
genome[msc14]:/home/people/msc14/alignment> cd
genome[msc14]:/home/people/msc14>
Wherever you are, 'cd' with no arguments will always take you to your home directory.


Simple file commands

To copy one or more file(s), use cp:
cp file newfile
cp file1 file2 etc... directory
To rename a file or move one or more file(s), use mv:
mv file newfile
mv file1 file2 etc... directory
To delete (remove) one or more file(s), use rm:
rm file1 file2 etc...
See the manual pages for details:
    man cp
    man mv
    man rm

Viewing and editing files

Text files

  • A very short text file can be typed on the screen with the command
    cat file
    (where you should substitute file with the actual name of the file).

  • Larger files may be viewed with a pager:
    less file
    which shows you one screenful at a time. When the viewing session starts you are shown the top of the file. You move around in the file as follows:
        SPACE	one screenful forward
        b 		one screenful backward
        RETURN	one line forward
        k		one line backward
        g		top (beginning) of file
        G		bottom (end) of file
        q		leave the session
    
  • If you want to create/modify a text file type
    nedit file
    A new window will appear and the file named file will be shown in it ready for editing. If file does not exist you will get an empty window in which to type. The 'nedit' editor is a Silicon Graphics editor in Macintosh-style with menus, mouse support, and on-line help.

Other files

Files containing graphics can be viewed with many different tools. The choice of tool depends on the format of the file in question. Most often it is mentioned in the exercise manual. Your browser is configured so that it in most cases will launch an appropriate tool when you view a file (select 'Open file' in the 'File' menu).


Viewing and saving output from commands

Often, a UNIX command will produce much more output than there is room for on the the screen at one time. In this case, there are two things you can do:
  • Pipe the output of the command through a pager:
    command | less
    (see above for how to use less).

    In general, the construct `command1 | command2' (known as a pipe) means that the output from command1 is used as input to command2. You will see examples of this in the exercises.

  • Save (redirect) the output to a file:
    command > file
    Then you can examine the file as described above, edit it, print it, or whatever you like.


Printing

The printer is in room 027 (marked with "Printer"). Files can be printed using the 'lp' command, just type:
lp < filename
where 'filename' is the name of the file you want to print (text file or postscript graphics file).

Output from a command can be printed directly using a pipe:

command | lp
It is also possible to print both text files and graphics directly from many Xwindows programs e.g. ghostview and nedit.


Manual pages

Most UNIX commands have manual pages which are viewed with the command man, e.g.
man align
The manual page for the command will automatically be piped to less (see above).


Getting help

There will be staff on duty to assist you in the course of the exercises. The questions concerning the computer system and the technicalities of UNIX should be put primarily to the support people:
    Hans Henrik Staerfelt,	room 011, phone 2471
    Peter Wad Sackett,		room 020, phone 2427
    Kristoffer Rapacki,		room 013, phone 2483
The questions concerning the exercise itself should be put to the teacher responsible for it. The above distinction can be fuzzy so you should generally grab whoever is at hand and ask for help.