Infrastructure

For this course, we will be using a virtual machine, namely Ubuntu, for working on and submitting problem sets. All problem sets can be run on other Linux machines or VMs, most problem sets can also be done on Mac OS X machines. However, we recommend you at least check your work on Ubuntu or another Linux VM, in case you are accidentally relying on Mac-specific behavior.

Download an Ubuntu VM

You will need an Ubuntu VM for some assignments. Most problem sets can also be run on other Linux machines or Mac OS X machines. However, we recommend you at least check your work on a Linux VM, in case you are accidentally relying on Mac-specific behavior. We recommend the latest LTS release or later, such as Ubuntu 18.04.3 LTS (Bionic Beaver). You can download it from Ubuntu here. Note that Ubuntu is free and you don't need to make a donation.

To run the VM, you will need to install a virtual machine monitor. We recommend using VMWare; VirtualBox also works well.

Note: VMWare Online Store account requests are manually approved, and it may take up to a day to receive a response. Do not wait until the last minute to claim your VMWare store account if you plan to use VMWare for your first problem set!

Mac OSX (VMWare Fusion)

You are now ready to create a new Ubuntu VM in VMWare Fusion.

Windows (VMWare Workstation)

You are now ready to create a new Ubuntu VM in VMWare Workstation.

Linux (VMware Workstation)

The problem sets should run on your Linux distribution, whatever it is, once you have the correct software installed. But if you run into trouble, you can install a virtual machine that’s running our preferred distribution.

You are now ready to create a new Ubuntu VM in VMWare Workstation.

Installing a C++ compiler

We will be using the GNU C++ compiler (g++) for our C++ projects. The C++ compiler is not installed by default. Here is how to install it in your VM:

sudo apt update
sudo apt install g++

This will install the GNU C++ compiler, g++, to the system. Once done, verify that you've got the compiler correctly installed by running

g++ --version

You will see output indicating the correct version of the C++ compiler is now installed. Any version greater than 7 should work.

Install tools

Run the following command to download install miscellaneous tools we will be using throughout the course:

sudo apt update
sudo apt install git kcachegrind linux-tools-generic qemu

When prompted, type y and hit Enter to approve the tool installations, and then you're ready to hack!

Version control with Git

We will be using git with GitHub Classroom for turning in problem set submissions and version control.

What is git?

Git was developed by Linus Torvalds for development of the Linux kernel. It’s is a distributed version control system, which means it supports many local repositories which each track changes and can synchronize with each other in a peer-to-peer fashion. It’s the best widely-available version control system, and certainly the most widely used. For information on how to use git, see:

Cloning the problem set repository

Problem sets will be released using the cs61/cs61-f19-psets repository.

Please click this link to create your own private clone of the problem sets repository. (The link will ask you to choose a name for your team; choose whatever you like.) You’ll clone that private repository onto your computer, do work there, and then push your work upstream to the GitHub-hosted repository for us to grade.

Here’s how it should work.

  1. Click the link.
  2. Log in to GitHub, or create an account.
  3. Provide a team name.
  4. The link should automagically clone the repository. For instance, if your team name was kohler-dumb, you should get a repository called cs61/cs61-f19-psets-kohler-dumb.
  5. Use the “Clone or download” button to clone your repository.

You can give other students access to your repository with Settings > Collaborators & teams. The collaboration policy allows students to share some code and even to commit to one another’s repositories. However, remember that every student is expected to submit separate code. GitHub access makes code sharing easier, but it also makes cheating easier. So make sure you and your collaborators have read the course collaboration policy and that you’re granting repository access only to people you trust.

Teaching GitHub about your identity

The easiest way to access GitHub repositories is using an SSH key, a secret key stored on your CS61 VM that defines your identity. This handy HCS tutorial may be useful to teach you about SSH; or just follow the steps below to create a key for your virtual machine.

  1. Launch your VM and open a terminal.

  2. Run ssh-keygen -t rsa -b 2048 and follow the instructions.

    • Press enter to use the default file path and key name (should be ~/.ssh/id_rsa).
    • Choose a password or leave it empty.

    This creates your ssh keys, which live in the directory ~/.ssh. Your public key is in the file ~/.ssh/id_rsa.pub.

  3. Run cat .ssh/id_rsa.pub to display your public key.

  4. Copy your public key (that is, select the text on the screen, and copy it to the clipboard).

  5. In GitHub, go to your profile settings page (accessible via the upper-rightmost link—this looks like a bunch of pixels for new accounts). Select “SSH and GPG keys” and hit the “New SSH key” button. Then copy and paste the contents of your ~/.ssh/id_rsa.pub file into the “Key” section. Give the key a sensible title, hit the “Add SSH key” button, and you’re good to go.

Creating a local clone

Once GitHub knows your SSH identity, you’re ready to clone your problem set repository and start doing work! Here’s how to get a local copy of the repo on your machine:

Troubleshooting

If you are having any trouble with your keys (e.g., you cannot clone a repo because "the connection timed out"), check if your firewall is blocking port 22, and open port 22 if it is blocked. You can use your favorite search engine to figure out how to do this.

Obtaining future problem sets

The following should be done every time a new pset is released or an old pset is updated.

This will download the latest pset directory into your repo.

Another way that’s convenient long-term is to add a handout remote to your repository. That works like this:

git remote add handout git://github.com/cs61/cs61-f19-psets.git

Now you can:

Submitting problem sets

Be sure that git status (from your “cs61-f19-psets-yourname” directory) reports that you have no uncommitted changes.

$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean

If git status reports that you have uncommitted changes, you'll need to commit these changes! Read through our Git tutorial for details.

Then, run git push, and be sure Git reports that everything is up-to-date:

$ git push
Everything up-to-date

Head over to the grading server and make sure that your code passes all tests you expect it to. The first time you visit the grading server, enter your official email address for the username (that will be your college.harvard.edu address if you are a college student and the email address you used when you registered for the class if you are an extension student). Then request a password reset. Once you've got your password, you can log into the grading server and enter the URL of your repository.

Obtaining lecture code

The code we’ll look at in lecture, and the lecture exercises, is available at the beginning of lecture in a public Git repository. Here’s how to obtain it the first time:

git clone git://github.com/cs61/cs61-lectures.git

This will put the lecture code in a directory called cs61-lectures.

To update exercise code for a new lecture, change into that directory and run git pull.