Jonathan P. Sorenson

Computer Science
   & Software Engineering
Butler University
4600 Sunset Avenue
Indianapolis, IN 46208, USA

sorenson@butler.edu
www.butler.edu/~sorenson

Fairbanks 158
Phone: 317-940-9765
Fax: 317-940-9014

Home Papers Personal Butler Brown Bag
CSSE Butler University
Program Grading Grading Writing Unix Help What is CS?
Blackboard Blue Mail Computer Lab Info DawgNet My.Butler.edu Libraries R&R Course Search Telnet to Thomas
ACM AMS EFF /.
Join the CAFE Campaign!
Join the Blue Ribbon Online Free Speech Campaign!

A Brief Unix Tutorial

How to Login

First, we'll discuss how to log in to thomas.butler.edu.

Using X-Windows from PCs

In the PC labs, you may run X-Windows to access thomas. To do this, follow these steps:

  1. With your mouse, press the start button.
  2. Select programs.
  3. From the programs menu select X-Win Fullscreen.
After a short wait, a login screen for thomas should appear. This is called the CDE or Common Desktop Environment for Unix systems. Enter your username, and after a short wait, your password.

Next, you need a terminal window, which will permit you to issue unix commands. To create one, look for the paper/pencil icon on the toolbar across the bottom. Click on the little arrow above it. You should see a menu appear. One of the selections is for a terminal window. Click on that selection.

(Note that you can get a simple graphical text editor, or the Netscape web browser from this menu too.)

Now move your mouse to the termial window (dtterm) that appears on your screen, and click in the window. You may now issue unix commands.

Using Telnet

Telnet is available from any PC or Macintosh on campus that is connected to the network. For PCs, you can invoke telnet from an icon labeled Email or QvtTerm on the desktop. Either a window for thomas will open right away, or you will have to select File/Open, and enter thomas.butler.edu.

You will be prompted for your username and password. Make sure the caps lock is off. You may now issue unix commands.

Other Information

To change your password, use the passwd command.

Sometimes commands you wish to execute are available, but your shell does not know how to find them. To fix this, you must alter your .profile or .login file, which sets the shell search paths when you login. Ask me to help you with this.

Use control-C to abort a command or program. Control-Z suspends the current process and puts it in the background, so if you don't know what this means, don't use it. Control-D is the end-of-file character.

How to Logout

Using X-Windows

On the toolbar is an exit icon. Click on this to logout from thomas. After a moment, the login screen should appear again. To get back to the windows desktop, press the windows button (between ALT and Ctrl in the lower left corner of the keyboard).

Using Telnet

Simply type exit at the thomas prompt.

Simple UNIX Commands

The command interpreter under unix is called the shell. There are several shells to choose from, with the most popular being csh, ksh, and bash. Below is a brief description of some common commands that are valid under all of these shells.

ls list all your files
more file display a text file on the screen
vi file edit a text file
pico file edit a text file (better than vi)
rm file remove (delete) a file
cp f1 f2 copy file f1 to f2
mv f1 f2 move or rename file f1 to f2
mkdir dir create the directory dir
cd dir change the current directory to dir
logout log off the system
man -k topic get a list of commands related to topic
man command display help information on a command
pine start the pine e-mail system
A file's pathname is denoted using the / character as a delimiter. The directory . is the current directory, and .. is the parent directory.

Under X-Windows, you can invoke an easy-to-use text editor from the paper/pencil icon on the toolbar. If you are using a telnet session, you will probably want to use Pico to edit files.

Compiling and Running Programs

You should create a text file containing the source code for your program. To do this, use an editor. One possibility is the paper/pencil icon under X-Windows, or vi or pico if you are using a text interface.

For a C++ program, the file you create must have a name ending in .c or .C, and you compile it using CC. The compiler generates an executable file called a.out, if compilation was successful. Here is an example for a C++ program:

pico myprog.c
CC myprog.c
a.out
For a Java program, create a file with a name ending in .java, and compile it with the javac program. You run the resulting .class file with java:
pico myprog.java
javac myprog.java
java myprog

Printing

To print a file from the command line, use lpr -Pprinter file. Here printer is one of the printer names listed below, and file is the text file you wish to print. (Please don't try to print binary files like a.out or myprog.class!) For example, to print the text file myprog.c on the printer in the PC lab in the basement of Jordan Hall, use lpr -Pjh-037-1 myprog.c. Here are more printers:

jh-037-1 for the JH037 PC Lab printer
fc-148-1 for the Fairbanks 148 PC Lab printer
fc-152-1 for the Fairbanks 152 SE Lab printer
For a list of additional printers, use lpstat -a.

Please do not try to print from the X-Windows text editor; it won't work. Instead, save your file and print from the command line.

Redirecting I/O

The output of any UNIX command may be placed in a file called filename by adding the argument > filename to the command. For example,

ls > filelist
will list your files and place that list in the file called filelist. Similarly, input is redirected by adding the argument < filename to a command. So, to run the program a.out using input from the file data and placing the output in file outfile, do the following:
a.out < data > outfile

Creating a Sample Run

There are two ways to record a sample run of a program. The first is to perform the sample run in a terminal window, select the text of the sample run with your mouse, and copy that text into a text editor. Then save it and print it.

The second method is to use the script command. Before beginning your sample run, enter script sample-file at the command prompt. Everything you type from now on goes both to the screen and into the text file sample-file.

Warning: Do not use a file name for sample-file that matches any other files you have; it will overwrite your file! I suggest using a name like myprog.sample to prevent this error.

Now perform your sample run. When finished, at the command prompt type exit. You should get a message confirming that the sample run was saved. Now print the sample run file.