1. Due Date

  • There is a soft deadline for this lab for this lab (before your weekly lab meeting). This is a warm-up lab that is not graded.

  • This warm-up lab contains instructions and tools necessary for starting and submitting Lab 1. You should try to complete as much as possible prior to the start of your weekly lab session.

  • We will also assist you with questions on Lab 0 in your weekly lab session. But you should get started on this and try to get as far as you can before your Week 1 lab session.

  • If you are new to CS courses, or if you’d like a review of using unix, attend one of the Using Unix Sessions: Tuesday 7pm and 8:30pm Sci Cntr 256, Wednesday 7-9pm Sci Cntr 240,

2. Lab Goals

  • Log into the CS lab machines

  • Reset your password, if necessary

  • Set-up course tools and resources, including git, gradescope, and EdSTEM.

  • Learn the basics (or refresh your knowledge) of Unix and useful Unix commands/tools

  • Learn the basics of the Vim text editor that you will be required to use on the first two lab assignments..

3. New User Setup

All work for CS31 will be done using your CS user account.

If this is your first CS course at Swarthmore, by Monday you will received an email from professor Danner (adanner@cs.swarthmore.edu) with your username and a link to reset your initially random password. Please follow the directions to set/reset your password for your CS account.

  • Read the CS lab rules and user rules off the CS help pages

  • Go to a CS lab (Sci Cntr 240, 256, and 238, and Clother 16) and login with your new account. It will ask you to reset your password. To logout, click on the logout icon logout and choose "log out".

    Alternately you can remotely log into into a CS lab machine using ssh (see Section 4 for more information).

  • Attend one of the Using Unix Sessions:

    • Tuesday 7pm and 8:30pm Sci Cntr 256, Wednesday 7-9pm Sci Cntr 240

4. Remote access with ssh (optional)

You do not need to do this as part of Lab 0, but here is some information for you if you’d like to learn how to remotely access CS lab machines with ssh.

ssh is useful for remotely logging into the CS lab machines. If you have never used ssh before, you may need to install an ssh client to connect to the CS machines from your home computer. More details can be found on the remote access help page.

You can remotely connect to a CS lab machine by sshing in with your username to lab.cs.swarthmore.edu or to a particular machine by specifying the full name, e.g., machinename.cs.swarthmore.edu. For example:

# log into some lab machine:
ssh yourusername@cslab.cs.swarthmore.edu
# log into owl:
ssh yourusername@owl.cs.swarthmore.edu
  • The CS help pages have a list of valid cs lab machines.

  • Using your ssh client, try connecting to the CS network using your CS username and CS password. Note that your username is probably the same as your ITS username, but your password may be different. You can always request a CS password reset online.

5. Unix Commands and creating a cs31 directory

If you are new to Unix, or would like a review, first read/skim section 17.1 in Appendix 2 of the course textbook. Focus on the Unix file system and the commands for moving around and creating directories, specifically: cd, pwd, ls, and mkdir.

Setup a directory for your cs31 work.

Log into a CS lab machine, and create a cs31 subdirectory in your home directory and cd into it.

Start a terminal and at the prompt ($) enter the following command sequence. Do not type the $. The #'s are explainations of each command and also shouldn’t be typed.

  [~]$ cd             # change current working directory to your home directory
  [~]$ pwd            # print current working directory
  [~]$ mkdir cs31     # create a new subdirectory named cs31
  [~]$ ls             # list contents of current working directory (your home directory)
  [~]$ cd cs31        # change current working directory to cs31
  [cs31]$ pwd         # print current working directory
  [cs31]$ mkdir labs  # create a new subdirectory labs inside the cs31 directory
  [cs31]$ cd labs     # change current working directory to labs
  [labs]$ pwd         # print current working directory

6. Learning Vim

Learn some of the basics of the Vim text editor. You will be required to use Vim on the first couple lab assignments in this class. If you know another Unix editor, you are welcome to use it on subsequent labs.

This section also has a short walkthrough video (from our all-remote semster) that may be of assistance if you get stuck getting started with vim: Vim and Vimtutor Video walkthrough. It is also covered in Appendix 2 of the course textbook.

The vi (and vim) editor is available on every Unix system. It 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.

  • It will be important to know the basics of vi/vim for some upper-level systems (Group 2) courses.

  • 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 is 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 insert at the cursor.

To learn the vim editor, run vimtutor:

  1. Either go to a lab and login to a lab machine, or ssh into our system and run vimtutor. Consult the help pages on remote access and ssh if needed.

  2. After creating a cs31 subdirectory in your home directory in the section above, change into this directory with cd:

      [~]$ cd          # go to home directory from current directory
      [~]$ ls          # list (ls) home directory contents
      [~]$ cd cs31     # change directories (cd) to cs31
      [cs31]$ pwd      # print working directory to show full path

    From within your cs31 subdirectory run the vim tutorial:

      [cs31]$  vimtutor     # start the vim tutorial
  3. 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)

6.1. Some Vim references

7. Try out Gradescope

We will use gradescope for submitting and grading homework and other written assignments in this class. If you are registered for this course, you will have a gradescope account. For some homework questions you may enter your answer directly in gradescope and for others you may upload an image or .pdf file with your solution in gradescope. We want to give you some practice trying both.

As part of Lab 0, we want you to create a .pdf file with your answers to the questions in this file:

Either print out the file and write your answers by hand, or edit the hw00.pdf file in some software to add in your answers.

Creating pdf files to upload in gradescope:

There two ways to create the pdf with your submission:

  1. Print out the .pdf of the assignment, hand write your answers to the question on the printout, take a photo with a smartphone or tablet of your answers, convert to a pdf, and upload it in gradescope. This is often the way in which you will submit homework assignments as most have space for your answers.

    For handwritten answers, make sure your writing is legible.

    printing pdf files from CS computers
    • In a browser you can view and print out the PDf file.

    • If you save the PDF file on our system you can open it in evince to read and print it.

      $ evince hw00.pdf
    • If you save the PDF to a file on your CS account, you can also print it from the command line using lpr.

      $ lpr hw00.pdf

    By default, if you print from a CS lab machine it will print to the printer in the lab in which you are working. Be sure to pick up your printouts and please don’t waste paper unnecessarily.

  2. Open the .pdf file in some software to write-up your answer. You could use software that you have on a tablet, or something else like googledocs or powerpoint. Edit the pdf adding in your answers, and save as a .pdf version with your answers to upload.

To submit

  1. Log into the CS31 Fall 2024 gradescope page for this class.

  2. upload the .pdf of your answers and submit it as your Lab 0 answer in gradescope. After uploading your answer check that it is readable, and try again if not.

8. Set up your Swarthmore GitHub account

You need a CS account to do this. If you don’t have one, we will hand out new accounts at the end of class on Tuesday, or see {system admin} outside of class to get your account.

Also, if you previously took CS 35 at Swarthmore, you have used the same tool and you can skip the creation of ssh keys as long as you remember your ssh key passphrase.

We will use Swarthmore’s GitHub Enterprise to get and submit lab assignments. Start by firt reading the Git Overview and Setup and Configuration sections of the Git Help page and then try cloning a copy of the Lab0 repo from the CS31 GitHub organization for our class.

All Swarthmore students should have a Swarthmore GitHub account connected to your ITS username and password. You can login to do some of the initial setup steps at Swarthmore GitHub.

8.1. Add SSH keys

If this is your first time using the college’s GitHub server for CS, follow the ssh-keys and config steps link from the Setup and Configuration directions for information on how to generate ssh keys and upload your public ssh key (generated from your CS account) that is necessary to clone repos on our system. Make sure you are logged into the CS network via ssh before creating your keys. It is possible, particularly on a Mac, to create keys just for your home machine/laptop, but that is not the goal here. Add your public key as a new SSH key on your Swarthmore GHE key settings.

If you get stuck on this step, we have a walkthrough video (from a previous semester) that may be of assistance: SSH key video

8.2. Clone Repo

Once you have added your key, you should be able to clone your repo on the CS network. This step will fetch a copy of the files from GitHub and copy them to your labs directory on the CS network. Replace userID below with your username.

[~]$ cd
[~]$ cd cs31
[cs31]$ cd labs
[labs]$ git clone git@github.swarthmore.edu:CS31-f24/Lab0-userID.git
[labs]$ cd Lab0-userID

If you get stuck on this step, we have a walkthrough video (from a previous semester) that may be of assistance: Cloning your first git repo video

8.3. Submit changes

If you successfully cloned the Lab0 repo, open the README.md file in an Vim and follow the directions for editing the file and then committing and pushing your changes using git.

[lab0]$ git add README.md             # 1. make this file part of next commit:
[lab0]$ git commit -m "readme info"   # 2. locally record changes with message:
[lab0]$ git push                      # 3. send changes to GitHub:

NOTE: you will not be able to access our course GitHub org or your Lab0 repo until Monday afternoon.

We will go over these steps in lab on {labday}, but please try this on your own before lab. We will help you during lab if you get stuck completing these steps.

You will need to remember to add, commit, and push each time you want to submit something for a grade. The push command sends files that have been added and committed to the GitHub servers, which is where graders and staff have shared access to your files. There is no grade for Lab0, but it is a chance for you to practice the steps needed for future labs. You can log into GitHub and check on your repo to see if your changes are there. If they are on GitHub, you did the steps correctly.

8.4. Some Git references

9. Sign into EdSTEM

We will use EdSTEM to help answer questions and post announcements. Try signing in and let us know early if you have any trouble connecting. There is a Lab 0 post, please try posting a response.

10. Handy References