This lab assignment will give you practice with unix, using a text
editor (emacs), and running our update21
and handin21 commands.
Start by reading through all of the CS21 homepage.
Pay special attention to the Schedule,
Academic Integrity and
Tips for success in CS21. 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.
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.
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
In a terminal window start the editor as follows:
$ emacs
A new editing window will open up. Click on the Help menu and select Emacs Tutorial. Start reading from the top. You can stop when you get to the section about "Buffers". As you read about each command in the tutorial, give it a try. This tutorial should take about 20-30 minutes to complete.
I have created a short Emacs Summary to help you remember the most frequently used commands. You may want to print this and bring it with you to class the first couple of weeks.
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/00The lab submission program, handin21, will grab all files from your cs21/labs/ 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
:
$ emacs bio.txt
Before you begin answering the questions, you can set up emacs so that it will automatically fill each line with the appropriate number of words. Press Esc-x, type auto-fill-mode, and then press Enter. You should see at the bottom center of the emacs window the word Fill appears. Now begin answering the questions.
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 bio.txt $ cat bio.txt ... contents of bio.txt file displayed here ...
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. Each time you
run it new versions of your files will be submitted. Running handin21
after you finish a program, after any major changes are made, and
at the end of the day (before you log out) is a good habit to get into.
Write a program called name.py that asks the user for their name and says "Hello", like this (what the user types is in blue):
$ python name.py Name: Jeffrey Hello, Jeffrey !
To create and edit a newfile, use emacs:
$ emacs name.py
Test your program several times, using different names. Once you
get your program running, turn it in by running handin21 again.
We will be using Piazza this semester as a way to quickly address
any questions that arise in the class. You can post questions to this
forum and the professors and students from any section can post
answers. Join Piazza (create a log in) and explore how to use it.
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 and the Terminal. Then click on the logout icon 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 lock
your machine while you are gone. You can lock by clicking on the lock icon
, or
by running the lock command in a terminal window.
You should not lock a machine if you
plan to be gone for more than about 10 minutes, and you should not lock the
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.
$ mv bio.txt ~/cs21/labs/00/bio.txt