CS21 Lab 0: CS lab resources for CS21

Due Saturday, January 22, by 11:59pm (see Section 11 for instructions on how to run handin21 to submit your lab).

If you have trouble completing this lab, come to our zoom office hours the week of Jan. 18, and continue to try out some of this after the due date.

Lab 0 Goals

The goals for this lab assignment are:

  • learn about the class

  • learn some remote tools that we will use at the start of the semester

  • learn how to log into the CS lab machines

  • gain some experience with Unix commands

  • learn the basics of the vim text editor

  • learn how to run our update21 and handin21 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

Off the the CS homepage there is lots of information about the CS program, activities, and policies. In addition there is a CS Help Pages link under the Quick Links list that contains useful information about CS lab policies, CS lab machines, and using software installed on our system.

Before using the CS system, you should read these two documents that are off these CS help pages:

3. Activate your CS account

All students in CS courses have accounts on the CS network computers. Your CS account is separate from your Swarthmore student account.

Before you can first log into the CS lab computers, you need to first set up your Swarthmore CS network account password.

Your CS username is the same as your Swarthmore College username, but your password and its management are separate (e.g., changing your college password has no effect on your CS password).

To activate your CS network account (or if you you ever forget your password) set your CS password using the CS Dept. Password Service page.

4. Connect to the CS labs using ssh

To connect to the CS machines from your dorm room, or off campus, you need to use the ssh program on your machine. Follow the Remote access using ssh directions.

We also have some walthrough videos showing how to use ssh (note: you need to be logged into your Swarthmore gmail account to access these):

If you have any problems connecting to CS lab machines with ssh, you will not be able to continue. Please contact your professor or Jeff Knerr (knerr@cs.swarthmore.edu) for help!

Once you are able to connect using ssh, you are ready to start the next part of the lab.

5. Try running update21

Note that we also have a short walkthrough video on the next two parts (update21 and Unix): Using Unix, update21, handin21

First log into a CS lab machine remotely using ssh (Section 3).

when we are back to meeting in-person, you will physically log into a CS machine in the CS lab and then open a terminal window (click the terminal icon) to follow these same directions.

Your prompt probably looks something like this, though there will likely be a machine name other than 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 (change directory) into the correct directory for lab 0

$ 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 via EdStem or email. It’s probably our fault.

6. 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 the Unix command line (there’s nothing you have to write or turn in). Make sure you understand the following commands:

  • ls list out files

  • cd change directory

  • mv move/rename a file

  • rm remove/delete a file

  • cp copy a file

  • pwd print working directory (where you are)

  • less show contents of file (one page at a time)

  • cat show contents of file (all at once)

  • exit close the terminal, log out of CS machine if using ssh

  • passwd change your CS password

If you have questions about these or get stuck, you may want to watch our short walkthrough video on update21 and some basic Unix: Using Unix, update21, handin21

7. Learn the text editor: vim

This semester we learn and will use the vim editor for editing files on our system. You will primarily use vim to create and edit files containing the python program code to run on our system.

This section also has a short walkthrough video to get you started learning vim: learning vim video

The vi and vim (Vi IMproved) editors are available on every Unix system. vim is an efficient and lightweight text editor that is easy to use after learning a few basic commands, which you can learn by running though the vimtutor tutorial.

vim is particularly useful when working remotely over an ssh connection.

vim also has many advanced features and is very configurable through, e.g., the use of a .vimrc file. However, just a few basic commands are enough to get you started.

Vim operates in two modes:

  1. insert mode: keystrokes are interpreted as inserts into the file contents at the point of the cursor.

  2. command or escape mode: keystrokes are interpreted as vim commands, which allow a user to do such things as saving, exiting, searching, or moving around in the file.

To switch from insert mode to command mode, press the ESC key.

There are many ways to switch from command mode to insert mode. One way is to press the i key.

To learn the vim editor, run vimtutor:

  1. first ssh into our system.

  2. if you have not yet done so, run update21 to create your cs21/labs/00 subdirectory

  3. then cd into your cs21/labs/00 subdirectory and run vimtutor to learn vim.

      $ pwd              # list current working directory
      $ cd               # go to home directory from current directory
      $ ls               # list (ls) home directory contents
      $ cd cs21/labs/00  # cd into your cs21/labs/00 directory
      $ pwd              # should list /home/you/cs21/labs/00
      $ ls               # list contents of current directory

    From within your cs21/labs/00 subdirectory run the vim tutorial:

      $  vimtutor     # start the vim tutorial
  4. Go through the sections listed below of vimtutor (the other sections cover more obscure features that are not necessary). It will take about 30 minutes to run through these lessons.

    • All of Lesson 1 (moving around, x, i, A, :wq)

    • Lesson 2.6 (dd)

    • Lesson 2.7 (undo)

    • Lesson 3.1 (p) and 3.2 (r)

    • Lesson 4.1 (G) and 4.2 (searching)

    • Lesson 6.2 (a), 6.3 ( R ), and 6.4 (y and p)

Some Vim Resources and Links

8. 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.

First see if you are in your cs21/labs/00 directory, and if not cd into it:

$ pwd              # print working directory

$ cd               # cd to your home directory
$ cd cs21/labs/00  # cd to your cs21/labs/00 directory

$ ls               # should see file named bio.tex

Then open the bio.txt in vim to edit it:

$ vim bio.txt

Note: this file should have a few simple questions in it for you to answer. If you don’t see those questions, exit vim, and then 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.

9. Run handin21

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

$ handin21

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!

10. 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 CS21 EdStem page, 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 post (non-anonymously) to the Lab 0 forum on the EdSTEM page. You could 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 in the Labs→Lab 0 forum to get practice posting questions and veiwing answers about specific lab assignments in their appropriate lab-specific forums on EdStem.

Lab 0 is a Subcategory under the Labs Category, that you should select when you post a new thread about lab 0. You can view the Lab 0 postings by expanding the Labs menu on the left and clicking on Lab 0.

students on the waiting list do not have access to the class EdSTEM page.

11. Answer the Questionnaire

Each lab will have a short questionnaire at the end. Please edit the Questions-00.txt file in your cs21/labs/00 directory and answer the questions in that file.

Once you’re done with that, run handin21 again.

12. Answer the Questionnaire

Each lab will have a short questionnaire at the end. Please edit the Questions-00.txt file in your cs21/labs/00 directory and answer the questions in that file.

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.

When Remotely logged in

When you are ssh’ed into the CS labs, first quit any applications you are running, like vim, then simply type exit at the prompt in your terminal window to disconnect.

When Physically logged in

When you are in a CS lab logged into a CS machine. First quit any applications you are running, like the browser and the terminal. Then click on the logout icon (logout icon or other logout icon) 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 xlock 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 meet us on Zoom

We will use Zoom for lectures and lab meetings during the first week of instruction in CS21 that will be remote (the week starting Monday January 24). If you are not familiar with zoom, you may want to review Using Zoom below.

During the week of January 18th, please come to one of the CS21 zoom office hours for this week to briefly introduce yourself and to check that zoom works for you prior to our first zoom synchronous meeting on Monday January 24. You may want to try to meet one of the professors who teaches either your lecture or lab section, but it is fine to meet with any of us.

You may also use any of these office hours for their regular purpose---to ask questions about vim, unix commands, and other parts of Lab 0.

The zoom office hours for the week of January 18 are (note: these times differ from our regular office hours for the semester, which are listed off the course webpage):

  • Andrew Danner (professor, CS21.1): Tues. Jan 18, 1:05-2:35, Thurs. Jan 20 10am-noon

  • Tia Newhall (professor, CS21.2): Wed. Jan 19 1:15-2:45, Thurs. Jan 20 11am-1pm

  • Ben Mitchel (professor, CS21.3): Wed. Jan 19 3-4:30, Fri. Jan. 21, 2-4pm

  • Lauri Courtenay (Academic support coordinator): Friday, Jan. 21 10am-noon

The zoom links for these meetings (and for lecture and lab meetings during the week of January 24th) will be emailed to you and also posted to the CS21 EdStem page. Contact your professor or Lauri Courtenay if you need help finding the class' zoom meeting link.

We expect that almost all of you will be able to meet to at least briefly say hello during one of these times. However, if you are not able to attend one of these sessions, send us a direct message on EdStem and we can try to set up an alternate time for you to try out our zoom meeting.

Using Zoom

If you have not used zoom before, you may want to look at instructions for using zoom off the college’s Working Remotely page.

You can also try out creating an using a zoom meeting with your one or more other Swarthmore students (e.g., another CS21 student, a friend, your RA, …​) by following these suggested steps:

  1. create a zoom meeting for you and your friend:

    • Name the meeting something (e.g., Zoomtest).

    • You can make it a one-time meeting for a specific time, or a Recurring meeting with the Recurrence→No Fixed Time option.

    • Enable join before host in the Meeting options

    • Save and send your lab partner the zoom link (Join URL associated with your meeting or copy the invitation link)

  2. contact each other to find a time for a 10 minute practice zoom meeting.

  3. at the time you arranged to meet, join your zoom meeting (because "join before host" is selected any of you can start the meeting).