Computer Science 322 Operating Systems

Mount Holyoke College Spring 2010

The purpose of this first lab assignment is to acquaint or reaquaint
you with the Unix systems in the CS department and how to run a C
program in those environments. None of these tasks is intended to be
hard, but if you don't have much Unix experience, they could be.
So...ask if you are not sure what to do! I expect plenty of
questions.

Logging into Unix Environments

We will be using several Unix-based systems within the Computer
Science department. Log into and familiarize yourself with your CS
Unix account in each of three environments. Later in the semester,
I hope to set up a Sparc/Solaris system for our use.

Log into a Linux system in Clapp 202. Boot into Ubuntu (the
Linux distribution we use) if they're in Windows or shut down
when you arrive.

Open a terminal window and execute this command:

uname -a > linux.txt

This will execute the command uname -a, which prints a
variety of information about the system you are on, and redirects
the output, which would normally be printed in your terminal
window, to the file linux.txt.

Set up ssh keys to allow remote logins among departmental Unix
systems without having to re-enter your password.

Create a new DSA key for your CS account:

ssh-keygen -t dsa

You may accept the default file name. You will then be prompted for a
"passphrase". You could leave this blank, but I recommend using a
fairly long (10 characters or longer) phrase. This will make your key
much more secure.

This will create two files in your .ssh subdirectory. You
will next want to copy your public key (in the file
~/.ssh/id_dsa.pub) to your list of authorized login keys (in
the file ~/.ssh/authorized_keys2):

Log in remotely to the Linux server, babyred.cs.mtholyoke.edu. Use a
Secure Shell (ssh) client, either from the Linux command line or
from elsewhere. The system should prompt you for a passphrase
(the one you just used to create your ssh key) instead of your
login password. Secure shell clients are standard on most modern
Unix-based systems (including Mac OS X) and are readily available
for Windows systems. You may also log into babyred
from elsewhere on the Internet, in which case you will use the
same password you use for the lab Linux systems. In either case,
once logged into babyred, you will have access to the
same files you have in your account on Clapp 202 Linux systems.

In your terminal window that is logged into babyred,
execute this command:

uname -a >> linux.txt

This is the same as what you did on your local Linux system, except
that we are using >> to redirect output. The difference is
that instead of creating a brand new file linux.txt (thereby
overwriting the previous contents of the file), the command will
append the output of uname -a to the end of the file
linux.txt.

Log into your account on the Macs in Kendade 307. The same files
you saw in Clapp 202 and on babyred will be
visible. Open a Terminal (go to Applications, the Utilities, and
click on the Terminal icon) and execute:

uname -a > mac.txt

Log into your account on the FreeBSD system mogul.cs.mtholyoke.edu. When
you are ready to do this, email me at jteresco AT mtholyoke.edu to make
sure your account is ready to go.

Once logged in, you should see your same files. On mogul,
execute:

uname -a > freebsd.txt

Look at the contents of the files linux.txt, mac.txt and
freebsd.txt. Which information is different? Can you guess what
some of the information in these files might mean?

Using appropriate commands from the above list, create a
directory for your work for this course called
cs322, change its permissions so that only you have
permission to read, write, and execute those files. Inside that
directory, create a directory for your work on this lab (call it
lab0), and move your .txt files from above into that
directory. Show that this has worked by issuing the following
command from inside of your cs322 directory:

ls -lad > ls.out

The Emacs Editor

Emacs (emacs from the Unix command line) is a powerful text
editor. You will want to become familiar with it if you are not
already. Identify the function of and experiment with these Emacs
commands:

C- before a key means hold down Ctrl and hit that key.
M- indicates the "Meta" key, which on most systems is Esc. To issue a Meta command, hit the Esc key, release
it, then hit the key for the command you wish to issue. Use the
keystrokes rather than the menus. It will save you time in the
long run!

Include a brief description of each Emacs keystroke in your file
unix.txt.

Learn these commands - you will use them often. Hints can be
found in the Unix and Emacs web pages linked from the course
website. Ask others in the lab if you're not sure how to do
something in the Unix environment. Share your tips and tricks with
each other.

Note: when logged into the Clapp 202 Linux systems, Emacs will open
in its own window and allow you to use the mouse to move the cursor
and to operate the menus. When logging in remotely, you need to
forward your X11 display to your screen. To do this from the CS
Linux systems, you will need to add the -Y flag to your ssh
command.

Verify that you can display an Emacs window from mogul.cs.mtholyoke.edu to
one of the Clapp 202 Linux systems. To get your prompt back (by
running Emacs - or any command for that matter - in the
background), follow your command line with an &. This will
allow you to work in Emacs and your terminal window concurrently.

Running a Simple C Program

Copy the C program here that computes the late
penalties for this course to your account. Compile and run it,
redirecting your output to a file late.txt.

Assuming you have copied the program into a file late.c, you
can do this with:

gcc late.c -lm
./a.out > late.txt

Copy the file /home/jteresco/shared/cs322/make-example.tar to your account.
It is a "tar file" of a small C program that demonstrates the use
of multiple source files and Makefiles. Extract the files
(tar xvf make-example.tar) and compile the program with
make. In a plain text file called make.txt, briefly
describe how make uses the rules in the Makefile to
produce the executable main.

Submission

To submit this lab, place all of the files that you are to turn in
(and nothing else) into a directory, change to that directory, and
create a "tar file" to submit.

tar cvf intro.tar *.txt ls.out Makefile

This will create a file intro.tar in your directory. Send this
tar file as an attachment to jteresco AT mtholyoke.edu by 2:40 PM, Monday, February 1, 2010.

Please include a meaningful subject line (something like
"CS322 Lab 0 Submission") and use the exact
filenames specified (for this lab and all semester) to make my job
easier when gathering your submissions together for grading. You
don't want to annoy your grader with misnamed or missing files just
before he grades your assignment. Please do not include any additional files, such as emacs backup files, object files, or executable programs.