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):
use the following hostname: id415mxx.cs.unb.ca (where xx is between 1 and 40). For example, to login from another Linux/UNIX machine:
$ ssh id415m17.cs.unb.ca
when prompted, type in your username and password (remember: both are case-sensitive - smith is not the same as SMITH!)
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
See the instructions for setting up racket for this course.
Start the interactive environment with
drracketRun your program with
racket foo.rkt(orgracket foo.rktfor graphical progams).If you want to use emacs as a development environment for racket, you can try geiser. On FCS machines, you can use my installed version by adding the following to your .emacs
;; 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
The -o test option will ensure that your executable is called hello and not a.out (the default)
The -Wall ("all warnings") option does some extra error-checking
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
The Glasgow Haskell Compiler is the "standard" Haskell environment
You can use ghc on the Faculty Linux systems with the commands ghci (interpreter) and ghc (compiler).
use
:helpfor a big list of commands in ghci. You need at least:load filenameif you don't use emacs haskell mode.If you see a complaint about libedit.so.0, then add the following to your .cshrc
setenv LD_LIBRARY_PATH /fcs/lib
or equivalently to .bashrc
export LD\_LIBRARY\_PATH=/fcs/lib
- Vim fans can add the following to their .vimrc (thanks to Paddy O'Brien for this tip)
: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
- To enable smart indentation of Haskell in Emacs, add the following to your .emacs
(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.