CS21 Lab 0: linux and xemacs

Due before class on Friday (Jan 25)

This lab assignment will give you practice with linux (aka "unix"), using a text editor (xemacs or vim), and running update21 and handin21.

1. Read the class web pages

Start by reading through all of the CS21 homepage. Pay special attention to the Schedule, Academic Integrity and How to succeed in CS21 parts. You should get into the habit of checking this page weekly; the class topics, lab assignments, weekly readings, and announcements will be posted to the class Schedule each week.

2. Read some useful CS web pages

Go to the CS homepage (http://www.cs.swarthmore.edu/). From there click on the "cs lab help" button and read the Welcome Message, The User Agreement, and The CS Lab Rules pages.

3. Learn some UNIX

Read through our UsingUnix web pages and try the various unix commands. Make sure you understand the following commands: ls, cd, pwd, passwd, less, cat, mv, rm, cp, ssh

4. Learn the editor... xemacs or vim

The preferred editor for my class is xemacs, but if you are comfortable with vim, you are welcome to use it. I find xemacs much more intuitive and expect that you will find the same to be true.

For either editor, you don't have to learn every single command. Just make sure you know the basics -- how to: open a file, add text to the file, delete text from the file, save the file, and quit the editor. Don't spend more than about 20-30 minutes on the tutorial.

Note for vim users, concentrate on the following sections of vimtutor:

5. Run update21 and edit bio.txt

Note: if you added CS21 late, we may not have you in our list of students who can run update21 and handin21. Send me email if you have problems and I'll add you to our list so that these will work for you.

Once you have learned how to use a text editor, run update21 (if you haven't already) to get the starting directory for lab 0, then move into that directory (enter the blue commands):

$ update21          # creates subdirectory 00 in your cs21/labs directory
$ cd                # cd to home directory (in case you are not there already!)
$ cd cs21/labs/00   # cd into the directory for lab 00
$ pwd               # check to see that you are in the correct directory.
                    # if you are, it will print /home/your_uname/cs21/labs/00
The lab submission program, handin21, will grab all files from your cs21/labs/00 directory. Each week, make sure you create your lab programs and files in the correct cs21/labs/XX directory!

Next, edit the file named bio.txt (e.g., xemacs bio.txt or vim bio.txt) and answer the questions in that file.

$ xemacs bio.txt       # for xemacs users
$ vim bio.txt          # for vim users

After you are done editing your bio.txt file, save your changes, exit the editor, then enter the ls command to list out all files. You should see the bio.txt file. You can also run the cat command on the file to see it's contents in the terminal window:

$ ls
$ cat bio.txt
... contents of bio.txt file displayed here ...

6. Submit

Once you are satisfied with your bio.txt file, hand it in by typing handin21 at the unix prompt.

Here is some information about how to run handin21.

You may run handin21 as many times as you like, and only the most recent submission will be recorded. This is useful if you realize, after handing in some programs, that you'd like to make a few more changes to them.

Logging out

When you are done working in the lab, you should log out of the computer you are using. First quit any applications you are running, like firefox or the Terminal. Then click on the logout icon logout and choose "log out".

If you plan to leave the lab for just a few minutes and then come right back to work, you do not need to log out, but it is a good idea to xlock your machine while you are gone. You can xlock by clicking on the xlock icon xlock, or by running the xlock command at the shell prompt. You should not xlock a machine if you plan to be gone for more than about 10 minutes, and you should not xlock main lab machines during times when classes are held in the lab.


If you can't find a file you created, check to see that you are in the directory you think you are.

If a file isn't in the directory you want it in, use the mv command to move it from its current location to a new location in your directory structure: The general form of the mv command is 'mv source destination', where 'source' is the pathname of the file you want to move and 'destination' is the pathname of the file you want to move it to. For example, if your bio.txt file is not in the correct cs21/labs/00 directory, here is how to move it to that directory:
  $ mv bio.txt ~/cs21/lab/00/bio.txt