From CS61
Jump to: navigation, search
Computer Science 61 and E61
Systems Programming and Machine Organization


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

Install a virtual machine monitor and the Appliance

If you have a Mac and are a current Harvard student (including extension), and you do not currently have VMware Fusion installed on your computer, please email the staff. Wait for a reply, and then follow the instructions below to obtain a VMap account and install VMware Fusion. Alternatively, you may install VirtualBox instead of VMware Fusion. However, VMware Fusion has significantly fewer issues with the appliance than VirtualBox, so we recommend filling out the form for VMware Fusion.

Follow the instructions here to install the CS50 appliance on your machine.

Update your appliance

  1. Open the terminal emulator (the shortcut is in the lower left corner, next to the Google Chrome icon).
  2. Type the following command and hit Enter. This may take a few minutes to complete.
     sudo yum -y update appliance50
  1. You may be prompted to approve the installation. If so, type y and hit Enter. If not, skip this step.
  2. Wait for installation complete, and that's it!

Install tools

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

 sudo yum install gcc-c++ kcachegrind perf strace bochs qemu

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

Version control with code.seas.harvard.edu

We will be using git with code.seas.harvard.edu for turning in problem set submissions as well as 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 by far the best version control system available to us and is increasingly widely used. For information on how to use git, see:

What is code.seas?

Code.seas is an online git repository and project management website for SEAS. It’s a deployment of gitorious, and acts somewhat like GitHub. We’ll be using code.seas for distributing code and problem sets, and for collecting your work.

Signing up for code.seas

The following only needs to be done once. You may skip steps 1-3 if you already have a working code.seas account.

  1. Go to https://code.seas.harvard.edu/login.
  2. Enter your FAS credentials. Extension school students, you can fill out a form to get a FAS account if you don’t already have one.
  3. You may be directed to an OpenID Verification page that asks you to confirm your identity. Click the "Allow Always" button on the right of the screen. You may then be asked to enter some details for your profile, but will eventually see your Dashboard.

The next step is to create and add SSH keys for your repositories. These keys authenticate you to code.seas, so that no one else can fake your identity. If you have a safe SSH key, use it. Otherwise, check out this handy HCS tutorial, or follow these steps:

  1. Launch your VM and open a terminal.
  2. Run ssh-keygen -t dsa and follow the instructions.
    • Press enter to use the default file path and key name (should be ~/.ssh/id_dsa).
    • 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_dsa.pub.

Finally, tell code.seas about this key.

  1. Now run cat .ssh/id_dsa.pub to display your public key.
  2. Copy your public key (that is, select the text on the screen, and copy it to the clipboard).
  3. In the SEAS Code Repository, click “Manage SSH keys”, click "Add SSH Key", paste your key into the field, and click "Save".

You are now ready to use git!

Code.seas 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.

If you are having any trouble logging in, please follow these steps:

  1. Quit your browser (flush cookies).
  2. Try to login to code.seas with your FAS account.
  3. If that fails, you may need to change your FAS password and repeat steps 1 and 2.
  4. If that fails, email Academic Computing at achelp@seas.harvard.edu and let them know your FAS account name. They will set up for you a local account.

Obtaining lecture code

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

     git clone git://code.seas.harvard.edu/cs61/cs61-lectures.git

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

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

Obtaining and submitting problem sets

We will be distributing and collecting problem sets using git and code.seas.harvard.edu.

Obtaining problem sets

Getting the problem set repo

The following only needs to be done once.

First, you'll need to clone the psets repo on code.seas:

  • Go to https://code.seas.harvard.edu/cs61/cs61-psets. Login to code.seas if necessary.
  • Click the "Clone repository" button.
  • This takes you to a new page, which gives you a chance to name your repository clone. Keep the suggested name (username-cs61-psets). Click the orange “Clone Repository” button.

Once your repository is created, you’ll be at a page that contains information about your new repository. You’re going to need the “Clone & push url” in a minute, so either copy the URL, or figure out how to get back to this page.

Next, make sure that the CS61 staff can view your repository.

  • On the right sidebar, click the "Manage collaborators" button.
  • On the right sidebar, click the "Add collaborators" button.
  • Click the "Add a team" tab, and add "cs61-staff". Be sure to give the cs61-staff team permissions to at least view and review (and commit, if you want), before clicking the orange "Add as collaborator" button.

Next, you'll need to get a local copy of the repo on your machine:

  • Launch your VM and open up a terminal.
  • Configure your git "identity":
     git config --global user.name "FIRST_NAME LAST_NAME"
     git config --global user.email "YOUR_@COLLEGE_EMAIL"
  • Execute the following command:
     git clone REPO_URL

where REPO_URL is the "Clone & push url" from step 4.

  • You will have a new folder called "username-cs61-psets", in which will be a subdirectory for the first problem set (and in the future, later problem sets).

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://code.seas.harvard.edu/cs61/cs61-psets.git

Now you can:

  • Fetch and merge new code with git pull handout master
  • Compare the handout code with your code with git diff handout/master

Submitting problem sets

Be sure that git status (from your "username-cs61-psets" 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.

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

$ git push
Everything up-to-date