CS21 Lab 0: Using Unix
Due Saturday, Jan 27, before midnight
The goals for this lab assignment are:
-
learn about the class
-
learn how to log into the CS lab machines
-
gain some experience with Unix commands
-
learn the basics of the Visual Studio Code text editor
-
learn how to run our
update21
andhandin21
commands -
practice using EdSTEM
Work through the following sections and ask if you have questions!
1. Read the class web pages
Start by reading through all of the class web page!
Pay special attention to the Schedule, Academic Integrity, and How to succeed in CS21 sections!
You should get into the habit of checking the class 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
From the CS homepage please read the user agreement and lab rules:
You may also want to peruse our lab documentation page:
3. Try running update21
Log into a CS lab machine and open a terminal window (click the icon).
Your prompt probably looks something like this, though there will likely be a
machine name other than flamingo
:
flamingo[~]$
As a shorthand, we will just use the $ symbol to indicate the prompt:
$
Our update21
command copies any files your professors want you to have from
them to your cs21
directory. It’s a good habit to run update21
each time
you log in. If you haven’t run it already, this will create your cs21/labs/00
directory.
Enter each of these commands below at the prompt. Do not type the # or anything after that: those are just helpful hints to explain what you are typing.
$ update21 # creates cs21 directory, with labs/00 dir below
$ cd cs21/labs/00 # cd into the correct directory for lab 00
$ pwd # check to see that you are in the correct directory.
# if yes, it will print /home/your_username/cs21/labs/00
If update21
doesn’t work for you, please alert your lab instructor. It’s
probably our fault.
4. Learn some UNIX
Read through our UsingUnix web pages and try the various Unix commands. These pages are just to help you get comfortable with BASH, a Unix command language and shell that implements the user interface running in the terminal (there’s nothing you have to write or turn in). Make sure you understand the following commands:
-
ls
list out files -
cd
change directory -
pwd
print working directory (where you are) -
mkdir
make a new directory -
cp
copy a file -
mv
move/rename a file -
rm
remove/delete a file -
less
show contents of file (one page at a time) -
cat
show contents of file (all at once) -
passwd
change your CS password
Optionally, you may also want to look over the ssh
command:
-
ssh
secure shell (how to connect to the CS machines remotely)
4.1. Try it out
To practice some Unix commands, in a terminal, try the following (link to answers are below):
-
cd
into your home directory (usepwd
andls
to "see" where you are, and to list a directory’s contents). -
Copy the file from
~admin21/public/welcome.txt
into your home directory using thecp
command. -
Run
ls
to see if your copy was successful (you should see a file namedwelcome.txt
in your home directory). if not, try again. -
Use
cat
to list the contents of thewelcome.txt
file. -
After you have successfully run
update21
then try this:-
List the contents of your
cs21
subdirectory that was created by runningupdate21
. -
Use
cd
to move into yourcs21/inclass
directory (usepwd
to "see" where you are). -
Use
cp
to copy thewelcome.txt
file from your home directory into yourcs21/inclass
directory (usels
to see if the file was successful copied).
-
Here’s a solution.
5. Learn the text editor: Visual Studio Code
Beginning this week we will start using the text editor in class, so you need
to at least know the basics. All professors teaching this course will use the
Visual Studio Code text editor. We will refer
to Visual Studio Code by the nickname "v-s-code", and we will use the command
code
to run the editor.
To practice using vscode, open up the practice.py
file in your
cs21/labs/00
directory and then follow the instructions in that file.
$ cd cs21/labs/00 # unless you're already in the labs/00 dir
$ code practice.py
Here’s a list of keyboard shortcuts to help you learn the vscode text editor. Make sure you at least know how to open a new file, add text, and then save it to the correct directory.
Always exit the
code editor when you are done using itVscode continues to use up a lot of computer (and energy)
resources when it is left idle. As a result, it is very important that
you exit It is also important to remember to log out of the CS machines when you are
done using them. We have special clean-up code that runs when you
logout of a CS machine that exits any |
If you already know another Unix editor (like vim or emacs), or at some
point want to learn one that is less resource-intensive than
code
(we recommend
vim),
you are welcome to use it instead of code
.
We will use code
as the official editor for CS21 (the one that
all the instructors and ninjas know, and the one that we will demo
in lecture), but you are welcome to use any editor that we have on our system.
6. Edit the bio.txt
file
For more practice with editing, and so that we can learn a little
about you, edit the bio.txt
file in your cs21/labs/00
directory:
$ code bio.txt
Note: this file should have a few simple questions in it for you to answer. If
you don’t see those questions, make sure you are in the cs21/labs/00
directory (i.e., run the pwd
command), and/or run the update21
command to
make sure you get the initial file from your professor.
7. Run handin21
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 (i.e., any files you’ve made changes
to). Running handin21
after you finish a program, after you make any major
changes, and at the end of the day (before you log out) is a good habit to get
into.
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/ directory!
|
8. Post to EdSTEM
This semester we’ll be using EdSTEM, an online Q&A forum for class discussion, help with labs, clarifications, and announcements that pertain to all sections of CS 21. Our EdSTEM page is https://edstem.org/us/courses/51529, and we have EdSTEM guidelines on the course home page.
For this first lab, just to get comfortable using EdSTEM, choose at least one
part of your bio.txt
file above to reply (non-anonymously) to the thread
already created in EdStem. The title of the post is "Lab 0 - for section 8 post
here". You can include where you are from, something else you are doing at
Swarthmore, your entire bio, or whatever you prefer.
When posting your introduction, please post as a reply to thread already created, not as a new post to the forum. |
9. Answer the Questionnaire
After each lab, please complete the short Google Forms questionnaire. Please select the right lab number (Lab 00) from the dropdown menu on the first question.
Once you’re done with that, you should run handin21
again.
Submitting lab assignments
Remember to run handin21
to turn in your lab files! You may run handin21
as many times as you want. Each time it will turn in any new work. We
recommend running handin21
after you complete each program or after you
complete significant work on any one program.
Logging out
When you’re done working in the lab, you should log out of the computer you’re using.
First quit any applications you are running, including your vscode editor, the browser and the terminal. Then click on the logout icon ( or ) and choose "log out".
If you plan to leave the lab for just a few minutes, you do not need to log out. It is, however, a good idea to lock your machine while you are gone. You can lock your screen by clicking on the lock icon. PLEASE do not leave a session locked for a long period of time. Power may go out, someone might reboot the machine, etc. You don’t want to lose any work!
Come to Office Hours!
As part of your Lab 0 grade, each student must visit the office of either their lecture or lab instructor. If you can come during our official office hours, that is ideal, but you are also welcome to stop by any time we are around. You do not have to have a specific question, you can just drop by to introduce yourself and learn where our offices are. We will have sign in sheets to check you off.
-
Section 1, Lab A: (Andrew Danner): Science center 247
-
Section 2, Lab D: (Chris Murphy ): Science center 252D
-
Section 3, Lab C: (Tia Newhall): Science center 249
-
Lab B: (Jocelyn Corey): Science center 252B