CS21 Lab0: Using Unix and Editing Files

Due: Complete before class on Wednesday

This lab assignment should get you used to running update21 and handin21 and give you some practice with Unix and editing files.

0. Using Unix Sessions

Don't forget to attend a Using UNIX session. You can attend either of these sessions (they are identical):
  Tuesday, Aug. 31, 4-5pm, 240 Science Center
  Wednesday, Sept. 1, 8-9pm, 240 Science Center


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 schedule, lab assignments, weekly readings, and quiz dates are available here.

2. Read the Computer Science web pages

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

3. Learn some Unix

To begin the assignment, open a Terminal window. You do this by clicking on the black square in the center of the toolbar terminal

When the Terminal window opens, you will see the shell prompt which will look something like this:
lemon[~]$

In the above prompt, lemon is the name of the machine you are working on, so this may be different for you if you are working on a different machine.

If you don't have one already, create a cs21 subdirectory in your home directory. Here is an example of the commands to enter to do this and to verify that it worked ('$' is the shell prompt and text after '#' are comments explaining the commands):

  $  cd                 # change current working directory to your home directory 
  $  pwd                # print current working directory
  $  mkdir cs21         # create a new subdirectory named cs21
  $  ls                 # list contents of current working directory (your home directory)
  $  cd cs21            # change current working directory to cs21
  $  pwd                # print current working directory 
Here is some information about the Unix directory structure.

4. Learn the editor xemacs

In your cs21 directory start the editor as follows:

 $ xemacs
A new window will open with a menu of options across the top. In the far right, select Help, then select Tutorials. The first choice (the default) is in English. Select the language of your choice and begin. Start reading from the top and focus on the sections entitled: You can stop when you get to the section entitled Buffers. This tutorial will take about 20-30 minutes to complete.

5. Run update21 and create 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 Unix editor program, run update21 to get the starting directory for the intial lab, then change into that directory:

$ update21             # creates subdirectory 00 in your cs21/labs directory
$ cd                   # cd into your home directory
$ 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, pwd should list: /home/your_user_name/cs21/labs/00
The program handin21 will only submit files in this labs/00 directory.

Next, start up the editor and open a new file named bio.txt:

$ xemacs bio.txt
In the file, answer these questions:
  1. Your name, year, and major(s) or intendend major(s) if known.
  2. What are some things that you are good at doing (they don't have to have anything to do with computer science).
  3. Tell me about any prior computer science experience you have (none is fine).
  4. Why are you taking CS21?
  5. Assess your current problem solving abilities.

After you are done editing your bio.txt file, save your changes and exit the editor. Run the cat command on the file to catalog it's contents to the terminal window:

 $ cat bio.txt

6. Submit

Once you are satisfied with your bio.txt file, hand it in by typing handin21 at the unix prompt. 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.

7. Sign up for a time to meet with me
There will be a sign up sheet on my office door, room 243, just across the hall from the computer lab. Sign up for a 15 minute slot to meet with me during the second week of classes.

Troubleshooting

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:
  # moves bio.txt from current working directory into my cs21/lab/00 directory
  $ mv bio.txt ~/cs21/lab/00/bio.txt

  # this does the same thing, '.' means a file with the same name as the source
  $ mv bio.txt ~/cs21/lab/00/.