UNB/ CS/ David Bremner/ teaching/ cs3613/ lab guide

CS3613 Lab User's Guide

The purpose of this document is to familiarize you with editing, compiling, running, programs in the Faculty of Computer Science Linux labs.

Facilities and Access

ITD415 has 40 Linux computers and is the primary Linux teaching lab. GWC112 has both Windows and Linux systems and can be used when ITD415 is unavailable or full. Note that these two labs are operated by Faculty of Computer Science (UNB-FCS), NOT by UNB's Integrated Technology Services (UNB-ITS). Although the computers in the FCS and ITS Windows labs use the same authentication server, and therefore the same passwords, this is NOT true for the FCS Linux labs.

Access to Faculty of Computer Science Labs is via the magnetic stripe on your student card. You will need to synchronize your FCS Linux password with your Novell PIN before you can start using the labs.

Login and Shell

In the following examples, "$" is a prompt from the shell, and is not to be typed!

You have two ways to login to one of the lab machines: In ITD415 (or GC112) simply login to one of the workstations From another location, use secure shell (ssh - use putty if you're logging in from a Windows machine):

In this course we'll often need to work from the command line, that is we'll use the bash shell directly via a terminal window. To open a terminal window, click on the terminal icon at the bottom of your screen.

Racket Hints

;; geiser on fcs
(let ((geiser-dir (expand-file-name "~bremner/pub/share/emacs/geiser")))
      (when (file-directory-p geiser-dir)
        (add-to-list 'load-path geiser-dir)
        (load-library "geiser-install")))

Compiling C

To compile (and link) hello.c and create an executable called hello, issue the following from the command line:

$ gcc -Wall -o hello hello.c

Note that on most Linux systems, cc is an alias for gcc.

Running Programs

To execute hello, type:

$ ./hello

The "./" is essential.

To execute hello taking input from file foo,

$ ./hello < foo

To execute hello taking input from file foo, and writing output to bar

$ ./hello < foo

Making a Tar archive

To bundle up a directory to hand in, you can use

tar zcvf dir.tgz dir

where dir is the directory name. To extract a (gzipped) tar file, you can use

tar zxvf dir.tgz

Making a typescript

To make a typescript (record of terminal session) use the script command. Type script filename to start recording your commands (and their output) in filename, and exit to stop.

Making a printout

To print a file, use the lpr command:

$ lpr hello.c

Haskell Hints

or equivalently to .bashrc

 export LD\_LIBRARY\_PATH=/fcs/lib
      :let hs_highlight_delimiters = 1
      :let hs_highlight_boolean = 1
      :let hs_highlight_types = 1
      :let hs_highlight_more_types = 1
      :let hs_highlight_debug = 1
      :let hs_allow_hash_operator = 1
(let ((haskell-dir (expand-file-name "~bremner/pub/share/emacs/haskell-mode")))
      (when (file-directory-p haskell-dir)
        (add-to-list 'load-path haskell-dir)
        (load-library "haskell-site-file")
        (add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
        (add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)))

With this haskell-mode, you can e.g. send your file to the interpeter from emacs with "C-cC-l". For more information, see the built-in help, accessible from "C-hm" in a haskell-mode buffer. Note that indentation matters in Haskell, so using TAB in haskell-mode to indent may save you some headaches.