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, Ubuntu 18.04.1 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 10)
- Fill out this Google form with your name, e-mail, HUID, etc, requesting VMWare Fusion 10 for Mac OS X. You will receive an account at the Software Center once your request is approved. Its user name and initial email address will both be your Harvard email address.
- The VMware Software Center is set up like a store. On the "store front" page, click on VMware Fusion 10. If you see both a free and a non-free offering of the product, choose the free one.
- Click the Add to Cart button, then proceed through the check-out process until you reach a screen with a Start Download button. Click the Start Download button to download the installer for Fusion 10.
- On the store front page, click on Your Account/Orders under the Hello, <your email> menu. Click on View Details to see your Serial Number. You will need that serial number the first time you try to run VMware Fusion.
- Click on the file you downloaded to mount the VMware Fusion icon on your desktop.
- Click on the VMware Fusion (or VMware Fusion.app) icon in the new window, click Open if prompted, and type your password if prompted. Follow the instructions to install Fusion 10. When prompted for a license key, use the serial number generated for you by the VMware Software Center.
You are now ready to create a new Ubuntu VM in VMWare Fusion.
- Launch Fusion
- Under the file menu, select
New
and select Install from disc or image on the left, and click Continue - Click Use another disc or image and browse to the iso file you downloaded, and click Continue
- Leave the Use Easy Install box checked and set a display name, username, and password like you would on any computer (as long as you remember it!), and click Continue
- On the next screen, click Customize Settings, and choose a location to save your VM (this is where VMWare Fusion will save a copy of the operating system)
- In the settings pop-up window, click on Processors and Memory, and allocate extra cores and memory to your VM. This will make things run faster and will make your life easier. We recommend at least 2 GB (2048 MB) and 2 processor cores. If you find that your VM is too slow, you can always change the memory/core allocation for this VM later in settings.
- Run the VM by selecting it in VMWare Fusion and clicking play!
Windows (VMWare Workstation 14)
- Fill out this Google form with your name, e-mail, HUID, etc, requesting VMWare Workstation 14. You will receive an account at the Software Center once your request is approved. Its user name and initial email address will both be your Harvard email address.
- The VMware Software Center is set up like a store. On the "store front" page, click on VMware Workstation 14.
- In the drop-down menu labeled Choose a platform, make sure that Windows is selected. Click the Add to Cart button, then proceed through the check-out process until you reach a screen with a Start Download button. Click the Start Download button to download the installer for Workstation 14.
- On the store front page, click on Your Account/Orders under the
Hello,
menu. Click on View Details to see your Product Key. - Click on the file you downloaded and launch VMware Workstation’s installer. If you are asked whether to allow the installer to make changes to your computer, enter your password, and click Yes.
- A window entitled Welcome to the VMware Workstation Pro Setup Wizard should appear. Click Next.
- When prompted with a license agreement, select I accept the terms in the license agreement, then click Next.
- You'll next come to a Custom Setup window. You need not change the Install Location. You'll probably want to select Enhanced Keyboard Driver, and then select Next.
- On the next screen, User Experience Settings uncheck the Help improve VMware Workstation Pro box and click Next.
- When prompted about Shortcuts, leave both boxes checked and click Next.
- You'll now come to the Ready to install VMware Workstation Pro screen; select Install. It will take a minute or two for the installation.
- When you come to the Completed the VMware Workstation Pro Setup Wizard screen, click on License, and paste the license key that you got from the VMware store. Then click Finish.
You are now ready to create a new Ubuntu VM in VMWare Workstation.
- Launch VMware Workstation
- Create a new virtual machine. Go to File > New > Virtual Machine.
- Select Custom and allocate at least 2 GB (2048 MB) and 2 processor cores to your new VM (keep the other default options).
- On the Guest Operating System Installation screen, when prompted where to install from, select Installer disc image file (iso).
- Click Browse, navigate to your downloaded iso file, and click Next to proceed through the new virtual machine wizard.
- Click Finish to power on the virtual machine.
Linux (VMware Workstation 14)
Fill out this Google form with your name, e-mail, HUID, etc, requesting VMWare Workstation 14. You will receive an account at the Software Center once your request is approved. Its user name and initial email address will both be your Harvard email address.
The VMware Software Center is set up like a store. On the "store front" page, click on VMware Workstation 14. If you see both a free and a non-free offering of the product, choose the free one.
In the drop-down menu labeled Choose a platform, make sure that Linux is selected. Click the Add to Cart button. If you receive a message saying "The platform of the product you have chosen appears to be different than the computer you are presently using. Are you sure you would like to add this product to your cart?" you can ignore it.
Proceed through the check-out process until you reach a screen with a Start Download button. Click the Start Download button to download the installer for Workstation 14.
On the store front page, click on Your Account/Orders under the Hello,
menu. Click on View Details to see your Product Key. Once you have downloaded the .bundle file, and make it executable before running it:
chmod +x VMware-Workstation-Full-14.1.1-7528167.x86_64.bundle sudo ./VMware-Workstation-Full-14.1.1-7528167.x86_64.bundle
Go through the steps presented by the installer (the default settings should be fine) and enter the Product Key when prompted for a license key.
You are now ready to create a new Ubuntu VM in VMWare Workstation.
- Launch VMware Workstation
- Create a new virtual machine. Go to File > New > Virtual Machine.
- Select Custom and allocate at least 2 GB (2048 MB) and 2 processor cores to your new VM (keep the other default options).
- On the Guest Operating System Installation screen, when prompted where to install from, select Installer disc image file (iso).
- Click Browse, navigate to your downloaded iso file, and click Next to proceed through the new virtual machine wizard.
- Click Finish to power on the virtual machine.
Installing 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++
It will install g++-7.3 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.
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 bochs 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:
- Our git notes, which include an explanation of version control in general
- SEAS’s git introduction
- Resources for more links
Cloning the problem set repository
Problem sets will be released using the cs61/cs61-f18-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.
- Click the link.
- Log in to GitHub, or create an account.
- Provide a team name.
- The link should automagically clone the repository. For instance, if
your team name was
kohler-dumb
, you should get a repository calledcs61/cs61-f18-psets-kohler-dumb
. - Use the “Clone or download” button to clone your repository.
Working with a partner? No problem. Find out their GitHub username, and then add them to your team as a collaborator using Settings > Collaborators & teams.
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.
Launch your VM and open a terminal.
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
.Run
cat .ssh/id_rsa.pub
to display your public key.Copy your public key (that is, select the text on the screen, and copy it to the clipboard).
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:
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 URL for your repository. This will be something likegit@github.com:cs61/cs61-f18-psets-yourname.git
, and can be obtained on GitHub by clicking the “Clown or download” button. You want to clone using SSH, not HTTPS, so you might need to click “Use SSH”.
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.
- Launch your VM and open a terminal.
- Navigate to your "cs61-f18-psets-yourname" directory.
- Execute
git pull git://github.com/cs61/cs61-f18-psets.git master
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-f18-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 “cs61-f18-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
.