DASP303 – Datalingvistisk modellering


English only

Getting started with Linux/Unix

Linux machines are provided in computer lab HF:123. This lab is used for teaching and for supervised and unsupervised exercises. The machines in the lab are managed by IT-avdelingen, and any hardware or system malfunctions must be signaled to bs.uib.no. Access to computers is reserved to students attending courses given in the lab. Physical access to the room is by means of your key card. The last person to leave the lab must remember to close all windows. Keep food and drink far away from the keyboard.

The operating system on the machines is Linux, a variant of UNIX. The purpose of this document is to give a brief introduction to Linux and to some of the programs available on the machines.


Brief Linux reference

The commands below can be typed in a terminal or console window. Some of those operations can also be performed in other ways, e.g. by selecting from menus.

Managing your session

passwd = change password

logout = log out

Control characters and other special characters

CTRL-c = interrupt (this is holding down the CTRL key while typing c

CTRL-d = end of input

CTRL-o = flush input

CTRL-u = kill line

TAB = complete (in tcsh or bash)

' ... ' = quotes: mark start and end of literal string

& = after a command, start as subprocess

< = input from file (only necessary for commands which normally do not take file argument)

- = input from keyboard (only for commands which normally take file argument)

> = output to file

| = pipe: output to program

Basic file and directory information

pwd = print current working directory

ls = list directory contents

ls -l = long directory list, gives more information

ls -a = list all files, also those beginning with period

cd dir = change working directory

more file = view file contents chmod o+r file = make file readable for others

Moving and removing files

cp file1 file2 = copy a file to another one

mv file1 file2 = move a file to a different name or place

rm file = remove a file

mkdir dir = make a new directory

rmdir dir = remove a directory (which must be empty)

ln -s file1 file2 = make a symbolic link which redirectsfile2 to file1

Inspection and manipulation of file contents

grep pattern file = search for lines matching the pattern in a file (use quotes if necessargy)

wc file = count characters, words, lines

sort file = sort (normally alphabetic)

sort -n file = numeric sort

sort -r file = reverse sort

sort -u file = sort and remove duplicates

uniq file = remove duplicate lines from a file

uniq -c file = remove duplicates and write duplicate count at beginning of line

Getting help

man command = manual

apropos keyword = search for commands about a keyword

which command = where is a command

whatis command = what is a command

date = show current date and time

Some examples of how to use complex commands

ls -la | more = list full directory contents, view output with more

sort file1 > file2 = sort file1, write sorted information to file2

sort file | uniq -c | sort -n = list unique lines in file sorted by frequency

Emacs

emacs & = start the Emacs editor. Can also be found in the menu. This editor is a very versatile program for writing all kinds of text, especially programs, and it can act as an interface to any other programs.

When the editor is started, it tries to find a file .emacs in the home directory and execute the commands in that file. A useful command in that file is the following, in order to allow the display of Norwegian and other European accented characters:

(set-language-environment "Latin-1")

In the Help menu is a tutorial and other information on how to use Emacs.

For using Common Lisp as a subprocess under Emacs, there are some useful interactive commands and keys, including the following. NB. The META modifier key is keyboard-dependent. On some keyboards it looks like a waving flag with a cross.

META-x run-lisp = start a Lisp subprocess.

The buffer *inferior-lisp* is used for direct interaction with the Lisp interpreter. The RETURN key evaluates a Lisp expression if it is complete. Use the Lisp function (quit) to quit using Lisp.

META-x lisp-mode = edit a buffer in Lisp mode, allowing the following keys:

CTRL-META-a = beginning of expression

CTRL-META-b = backward expression

CTRL-META-f = forward expression

CTRL-META-q = indent expression

CTRL-META-t = transpose two expressions

CTRL-x CTRL-e = evaluate expression

CTRL-c CTRL-e = evaluate definition

CTRL-c CTRL-r = evaluate the selected region

CTRL-c CTRL-d = describe symbol

CTRL-c CTRL-l = load Lisp file

CTRL-c CTRL-z = switch to the buffer *inferior-lisp*

N.B. If you have a keyboard without Norwegian characters, you can type them by switching to the following mode:

META-x iso-accents-mode = edit a buffer in iso-accents-mode, allowing e.g. the following keys:

/ o = ø

/ a = å

/ e = æ

/ SPACE = /

' e = é

' SPACE = '

etc.

Installation of SLIME:

cd ~
mv .emacs.d .emacs.d-old
wget tinyurl.com/dasp101
unzip emacs-conf.zip

After that you can start with META-x slime

© Koenraad de Smedt 2003-2009