Unix Survival Kit

Items in bold should be typed exactly as they appear here.
Items in italics represent a user-supplied entry to be typed.
All Unix commands are case sensitive (ABC is different from Abc).


navigating the system

..% login: user-id log into Unix password: password ..% stty erase del set the del key to backspace (in case it's not already set) ..% netscape & start the web browser
... then you can Open the desired web site - e.g.: http://www.cs.ou.edu/cs1323h
... or click on the tiny envelope icon to send or read email ..% ls -l list the contents of the current directory ..% ls -l directory-name list the contents of the specified directory ..% mkdir directory-name make a new directory ..% rmdir directory-name remove a directory (must contain no files) ..% cd directory-name go to the indicated directory (must be child of current working directory) ..% cd .. go to the parent directory of the current working directory ..% pwd report the current working directory (where you are) ..% exit log out
. (a single period) designates the current working directory.
.. (two periods) designates the parent of the current working directory.

file operations

..% more file-name display the contents of the indicated file on the screen; space bar continues display ..% lpr file-name print the indicated file on the default printer ..% lpr -Pprinter-name file-name print the indicated file on the specified printer ..% mv old-file-name new-file-name rename the indicated old file ..% mv file-name directory-name move the indicated file to the specified directory ..% cp file-name new-file-name make a copy of the indicated file ..% rm file-name delete (remove) the indicated file ..% pico -w file-name create or edit the specified file using a pint-size commodious editor ..% vi file-name create or edit the specified file using a very incommodius editor (see below)

vi operations

vi has two "modes" - command mode and text insertion mode; it starts out in command mode.
i, A, and o put it into insertion mode; esc (the escape key) returns it to command mode.
The command-mode commands are:

h move cursor left one character j move cursor down one line k move cursor up one line l move cursor right one character x delete character at cursor position dd delete line that cursor is on /string move cursor to next occurrence of string :n move cursor to nth line . repeat previous command :w save file i begin insertion mode from current cursor position (must press esc to return to command mode) A begin insertion mode at end of line (must press esc to return to command mode) o begin insertion mode on new line (must press esc to return to command mode) :q exit vi Any file-name or directory-name may be preceded with a path.
A path is a sequence of one or more directory-name/ segments.
For example: haskell/proj1/proj1Script.lhs

compiling and running programs

..% hugs file-name.hs start a Hugs session using the indicated file as a Haskell script
..% hugs file-name.lhs start a Hugs session using the indicated file as a Haskell script (in literate format)
..% gcc file-name.c compile a C program file into the executable file
a.out ..% gcc file-name.c file-name.o compile a C program file and an object file into the executable file
a.out ..% gcc file-name.c -o e-file compile a C program file into the executable file
e-file ..% gcc file-name.c -c compile a C program file into object file
file-name.o ..% a.out perform the computation specified in the executable file
a.out ..% a.out > output-file-name perform the computation specified in the executable file a.out and put its output in
output-file-name ..% a.out < input-file-name perform the computation specified in the executable file a.out and gets its input from
input-file-name ..% e-file perform the computation specified in the executable file
e-file ..% e-file > output-file-name perform the computation specified in the executable file e-file and puts its output in
output-file-name ..% e-file < input-file-name perform the computation specified in the executable file e-file and get its input from
input-file-name
Many other combinations are allowed. For example, any number of .c and .o files can appear in any combination in one gcc command. Related functions should be packaged in separate .c files, (like modules in Haskell) and this file can be turned into a .o file before the program using that module is compiled; alternatively both the main program and the module .c files can be compiled together (in which case the modules are recompiled every time the program is recompiled).


CS 1323 Section 30 - Fundamentals of Computer Programming - Spring 1997
Instructor: Rex Page (Email: page@ou.edu)
Up to: Welcome Page ~~~ Up to: University of Oklahoma ~~~ Go to: Next Semester ~~~ Go to: Previous Semester
Last Modified: Friday, 02-Dec-2005 11:43:36 CST