Deadline: Friday, January 29 at 11:00:00 PM PT (extended by 1 week for this lab only)
Hello! Welcome to CS61C! We’re excited to have you on board :D
Please pay attention as we demonstrate the safety features of this aircraft.
This lab may be a little long, but please read carefully; it covers many important things that will prepare you for the rest of the course!
Each lab will begin with a few objectives; use them to reflect on your learning and guide your thinking! Here are the objectives for this lab:
A quick clarification on some terms:
You can view the course policies on the policies page of the course website. You are responsible for understanding and adhering to all policies throughout the course of the semester. Please pay particular attention to the
Academic Dishonesty and Cheating sections.
Unfortunately, assignments in this course do require some (sometimes boring) setup. Let’s get that out of the way.
CS 61C primarily uses a couple services for distributing assignments, receiving work, and grading. There’s a brief overview of the important ones in the sections below.
If you’re enrolled CS 61C normally, you can ignore this blurb.
If you’re a concurrent enrollment student, in CS 47C, resolving an incomplete, or in some other non-standard enrollment for CS 61C, you might not be able to access some of the resources below. If that is the case, please fill out this form so we can add you.
Most students should have a CalNet ID (and therefore, email ending in
@berkeley.eduemail if possible. This is your “Berkeley Google account” (or bConnected account, but nobody says that).
Piazza is a discussion forum that we’ll be using as the main method of communication for this course. All announcements will be made here, and almost all questions or comments you may have should be posted here (unless we say otherwise).
We’ve already emailed invites to the 61C Piazza course to most enrolled students. If you’ve recently enrolled, this may be delayed by several hours while the campus systems process your enrollment.
Please read through the Discussion Forum section of our policies. Please remember and follow the Piazza Etiquette!
Gradescope is the platform we use for submitting and grading assignments. Programming assignments, homework, and quizzes will be submitted here.
We’ve already added enrolled students to the 61C Gradescope course. To sign in, visit Gradescope, click
Log In, then
School Credentials, then
Warning: Please ensure you set your
@berkeley.edu email as your primary email. If not, we might not be able to find your Gradescope account, so you might not get credit for your work!
GitHub is a hosted Git service we use for code distribution.
If you have an existing GitHub account, feel free to use that; repositories created in this course are private, and anything you do for this course shouldn’t affect the rest of your GitHub account.
If you don’t have a GitHub account or want to make a separate one for schoolwork, sign up at GitHub.
Lectures will be uploaded to Kaltura. Other video resources will be uploaded to either YouTube or Kaltura.
Kaltura: Under the bCourses site for this course, there is a
Media Gallery page. Kaltura uploads should be visible here.
YouTube: YouTube uploads will be linked on the course website. You will need to be signed into YouTube using your Berkeley Google account to view our YouTube uploads. If you’re unable to view a video on YouTube, make sure you’re using your Berkeley Google account (click your avatar on the top-right corner and
Switch Accounts, or try the Channel Switcher page).
We will be holding meetings (lab/project/general OH, lectures, discussions, etc.) through Zoom. When signing in, use the
Sign in with SSO option, enter
berkeley.zoom.us, and sign in with your CalNet ID.
Regularly scheduled meetings (e.g. OH, discussions) will be held in standing Zoom rooms. The links for these can be found in the Zoom Links Piazza post.
Office Hours (OH) will be scheduled and managed through the OH Queue. Please use your Berkeley Google account when logging in; non-Berkeley Google accounts will not be able to use the OH Queue properly.
Please read the blue info box on the OH Queue page. If you’re having issues, let staff know using the ticket chat.
The “Hive” is a group of servers maintained by the EECS department. Campus is not exactly open right now, but they live in Soda 330 if you ever want to give them a hug! You can intearct with these servers remotely through SSH and the command line (more on that later). We’ve already installed most of the software we’ll be using on the Hive machines, so you can work on most assignments on the Hive if you want! You can find a list of Hive machines at Hivemind (only the names starting with
You will need to sign up for a
cs61c instructional account, which you’ll use to access the Hive. We’ll also be using your instructional account username as your primary ID for checkins.
Note: If you can’t create an account for whatever reason, don’t worry! See the Non-standard Enrollment section, and continue without an account for now.
Spring 2021version of the
If you took CS61A and CS61B, you likely have some experience with a command line interface (CLI) and terminal commands. We’ll be using the CLI a lot in this course, so let’s take a moment to review some of the basics.
Example commands will be formatted like:
$ command arg1 arg2
Typing that (without the
$) in your terminal will run the command. In this case, it just prints
Flags are commonly used to specify program options or alter behavior. They usually begin with one or two dashes, and can optionally take an argument.
$ command --help $ command -f flag_arg
You may find it helpful to review 61B’s list of common CLI commands.
When typing commands or file paths:
<tab>will autocomplete the current term
<down arrow>will allow you to refill commands you’ve used previously without typing them again.
<ctrl> + awill move the cursor to the beginning of the current line (helpful for fixing mistakes)
<ctrl> + ewill move the cursor to the end of the current line (also helpful for fixing mistakes)
<ctrl> + rwill let you search through your recently used commands
echo repeats whatever arguments you give it.
$ echo "Hello World" $ echo "dame da ne\ndame yo, dame na no yo"
touch will create a blank file with the file name you provided.
$ touch example.txt
This will create a file named
example.txt with nothing inside.
If you’d like to create a file and add text in one go, you can use:
$ echo "Your contents here, inside double quotes" > example.txt
This will create a file with the name
example.txt in your current directory. If the file already exists, it will be overwritten. The file will contain
Your contents here, inside double quotes but without the double quotes. The
> symbol takes one argument which redirects where data printed to stdout is sent. Here, we are redirecting the output of
echo to a file named
You can also use the
echo command by itself, in which case it will print the string to the terminal (without creating a file in the process).
You can view the contents of a file with the
$ cat example.txt $ less example.txt
cat print the contents of
example.txt to your terminal.
less opens a basic viewer which allows you to scroll and search.
You can provide a relative or absolute path to print out non-local files:
$ cat ../other_folder/file.txt $ cat ~/home_file.txt $ cat /creeper/awww_man
man- Manual Pages
The manual pages (“man pages”) are great UNIX resources that are often underused; while not as versatile as Google, they contain documentation on UNIX components from program usage, language standards and conventions, and more. They also work offline, so they can be handy if you’re ever stuck in a North Alaskan woodland cabin in the middle of a snowstorm basking in the dying glow of a ThinkPad which BTW runs Arch Linux.
While your favorite search engine probably also has the answers you’re looking for, in this course, we’d still like you to get comfortable with using
man, especially for C and UNIX-related questions.
If you want the man page for a single program/command, you can run:
$ man command_name | less
The man page for a program typically contains information about what the program is used for, what certain flags do when you invoke the program with them, and where to go for more information. Since we piped the man page into
less, this page is scrollable (use your arrow keys or the space bar). Hit
q to exit the man page and get back to your terminal prompt.
$ man echo | less
The above command should bring up the man page for the
If you want to search the man pages for a command that pertains to a keyword:
$ man -k single_keyword | less
This command will search the manual pages for a command with the keyword
single_keyword. Forget how to open files in Vim? You can search for
editor and get a list of all editor-related commands on your system.
ssh- “Secure Shell”
For this class, we’ll expect you to test most of your projects, homeworks, and labs on the Hive machines. To access the Hive machines remotely, you’ll be using the SSH protocol and programs.
Note: If you weren’t able to get an instructional account, you can come back here later!
You can find a list of Hive machines at Hivemind. There are 30 of them, named
hive30. If its name starts with
hive, it is a Hive machine. If it doesn’t start with
ashby), it’s not a Hive machine. Using a non-Hive machine may lead to weird setup/runtime errors.
Sometimes, a Hive machine may be down or overloaded. If you’re getting “
Connection refused” or “
Connection timeout” or other connection errors, check Hivemind and pick another machine to use.
Once you have an instructional account, you can SSH into an instructional server with the following command:
$ ssh cs61c-???@hive#.cs.berkeley.edu
Remember to replace
cs61c-??? with your instructional account username, and
hive# with a Hive machine’s name. The default password is displayed by WebAccount when creating the account, so you might have to reset your password if you forgot it.
CalVisitoron campus, block SSH. Try another network (
eduroamif you’re on campus).
Permission denied, please try again: if you’re copy-pasting the password, try typing it out manually.
Connection refusedor other weird errors: the Hive machine you picked might be down. Try another one
Reserved for cs61c staff: try another Hive machine :)
When your connection succeeds, you should be able to interact with and run commands on your chosen Hive machine! To exit this SSH session, simply run:
Files on the Hive machines are stored on a network drive, so your account will have the same files on all 30 machines.
Note: If you want to change your instructional account password, you can SSH into the update server:
$ ssh firstname.lastname@example.org
When you’re in a SSH session, your prompt should look similar to this (the area inside, but not including, the red box):
If it looks very different (e.g. the prompt is white text instead of red and yellow text), try running
If your prompt still looks very different, contact course staff on Piazza.
scp- “Secure Copy”
scp program is used for copying files between computers using the SSH protocol.
Sometimes, you may want to get individual files or entire folders from the Hive machines onto your
local system, or vice versa. You can do this by using
$ scp <source> <destination>
To specify a remote source or destination, use
username@host:path. To specify a local destination,
path. As an example:
$ scp email@example.com:~/some_folder/example.txt ~/Downloads/
Assuming my username is
cs61c-???, the above command would connect to
hive3 and copy
~/some_folder/example.txt on my instructional account to
~/Downloads/example.txt on my local
If I wanted to copy the other direction (from my local machine to a Hive machine) I would use:
$ scp ~/Downloads/example.txt firstname.lastname@example.org:~/some_folder/
scp by default only works with files. To copy folders, you need to tell scp to “recursively” copy
the folder and all its contents, which you can do with the
$ scp -r email@example.com:~/some_folder ~/Downloads/
scp on the Hive machines (e.g. when you’re in a SSH session) is usually not desired behavior. Running
scp example.txt firstname.lastname@example.org:~/example.txt on a Hive machine will copy
example.txt to… the same place. You probably want to run it in a local terminal session!
vim is a text editor included on the Hive machines and many UNIX-based distributions.
Note: We’ll be using Vim in most of our examples and documentation, but we have no hard requirement on which text editor you use; you’re welcome to pick whatever you’re comfortable with, but you should know how to use at least one terminal-based text editor.
To open a file from your current directory, pass the file name to Vim:
$ vim filename
To open a file from another directory, use a relative or absolute path:
$ vim ../other_folder/filename
Some useful Vim commands:
||Closes (quits) Vim without saving|
||Closes Vim after saving|
||Saves your file|
||Force-quit Vim (for when you’ve made changes but do not wish to save them)|
||Insert mode, allows you to type into the file|
||Searches your file for the nearest occurrence of the string “cats”. Press
||Shows line numbers within your file|
Note: these commands are preceded by
<escape> because you’ll need to press the escape key on your
keyboard to switch you out of your current mode. For example, if I’m inserting (typing) into a file
and want to save, I’d have to hit
<escape> to get out of insert mode, then type
:w to save my
file. If you aren’t in a mode (i.e. you’ve just opened your file) you don’t need to hit escape
first, but it won’t hurt :)
For more on Vim, one of our summer 2020 tutors, Yijie, wrote a great Vim for CS61C guide!
SSH into any Hive machine. Then:
check-register, and verify that your name, email, and student ID are correct. If anything is incorrect, run
In this exercise, you’ll get your labs Git repository (“repo”), use Vim, and work with a variety of Git commands. By the end of it, you should feel comfortable using SSH, editing files, pulling/committing/pushing, resolving merge conflicts. If you’d like to review your Git commands before beginning, you can check out this guide.
Visit https://galloc.cs61c.org. Log in, connect your GitHub account, and start the lab assignment. A GitHub repo will be created for you; this will be your personal repo for any lab work you do throughout the semester.
Before we start, let’s tell Git who you are. This information will be used to sign and log your commits. You may not need to do this if you’ve set up Git before, but if you’re on the Hive machines it’s likely a step you’ll need to take.
First, run the following commands on your local machine (make sure to change the name and email to match your information):
$ git config --global user.name "John Doe" $ git config --global user.email email@example.com
If you have an instructional account, SSH into a Hive machine, and run the same commands.
Git has the concept of “local” and “remote” repositories. A local repo is located wherever your terminal session is; if you’re in a SSH session, the local repo is a folder on a Hive machine; if your terminal session on your local machine, the local repo is located on your local machine’s filesystem. A remote repo (e.g. GitHub repo) is typically hosted on the Internet.
You have a lab repository on GitHub, but not locally (it would be a little worrying if a website could automatically access your local files). To get a local copy of this repository, you can use
git clone, which will create a local repository based on information from a remote repo.
If you have an instructional account, SSH into a Hive machine. On the Hive clone the repository into a folder called
$ git clone GITHUB_REPOSITORY_URL labs
If you don’t have an instructional account, that’s fine! Clone the repository into a folder called
labs_hive. For the rest of this exercise, any reference to your repository on the Hive is referring to this repository.
$ git clone GITHUB_REPOSITORY_URL labs_hive
cd into this new folder. List all hidden files (
ls -a). Do you see a hidden file/folder?
There is indeed a folder called
.git. Its presence indicates that the current folder (folder containing
.git) holds a Git repository.
Take a look at your repo’s current remotes and status:
$ git remote -v $ git status
git clone has already worked a bit of magic here; there’s a remote called
origin, and its URL points to your labs repo on GitHub! You’re on a local branch called
master, which is “tracking”
master branch on the
Throughout the semester, course staff may make updates to starter code to fix bugs or release new labs. To receive these updates, you’ll need to add another remote.
$ git remote add starter https://github.com/61c-teach/sp21-lab-starter.git
If you ever want to pull updated starter code, you’d execute the following command:
$ git pull starter master
Try it out now! Since you just started lab, there might not be any updates to pull yet.
Warning: please read carefully. Skipping a step may cause errors that will require you to redo the exercise.
The files for this exercise are located in the
lab00 folder in your lab repository.
The main goal of this exercise is to get you familiar with manpages, Git, and other programs, but not to stress you out over finding commands. If you’re stuck trying to find a command, write your best-effort guess, and the autograder will give hints if the command isn’t what we’re expecting.
first_set.txt. This file contains descriptions of UNIX commands. Use the man pages to figure out which command they refer to (if you’re stuck, you can try searching the internet). Make sure to include any necessary flags. Once you’ve found them, write the commands, one per line, in the provided
answers.txt should look similar to (including the numbers):
Save, add, and commit your changes with the commit message
"Answered first set". Push this commit to your GitHub repo.
Now, we’ll need to copy the repository to your local computer.
exit. You should be back to your local terminal prompt. Use
scpto copy the entire
labsfolder from the Hive to your local machine (refer to Exercise 3 for a refresher on
scp). Hint: what does the
labs_hivefolder to a separate
Once you’ve copied the entire folder,
cd into this folder and open your answers file.
Above your previous answers, add commands (and relevant flags, if needed) that fit this second set of descriptions:
answers.txt should look similar to (including the numbers):
Save your changes, but do not commit or push them.
Go back to your repo on the Hive. Above your previous answers, add the command (and relevant flags, if needed) that fits this description:
answers.txt should look similar to (including the numbers):
Save, add, commit, and push these changes with the commit message
"Answered third set".
Go back to your repo on your local machine. Add, commit, and push your changes with the commit message
"Answered second set".
You should get an error message from Git. What does this message mean? How do you resolve it? When resolving this issue, avoid using the rebase command or flags.
After resolving the issue, you should have all your answers in
answers.txt on your local machine.
answers.txt should match the following (including the numbers):
Commit and push your changes.
To submit your work, push your work to your lab repository on GitHub.
Every lab will have autograded exercise(s). To submit to the autograder, you’ll need to push your work to your lab repository on GitHub. Then go to the corresponding assignment on Gradescope (
Lab00: Intro and Setup for this lab), select your lab repository, and submit. After a short wait, the page should show your autograder score for the lab.
Remember, to get credit for a lab, make sure you have finished all the exercises and passed all the autograder tests by 11:00:00 PM PT!
You made it! That was quite a bit of reading and head-scratching, but you’re now somewhat more familiar with the tools you’ll be using for the rest of the semester. Worth it!
Please check that you and your partner have:
Lab Autograderfor this lab
These are some tools you may find helpful, but are by no means required for this course :)
CS61C doesn’t endorse any particular text editor or IDE. Many people get by in this course using a text editor with no frills (think: Vim/Emacs/Nano). We’ll expect you to know how to use at least one CLI-based text editor, since you’ll be dealing with the command line a lot.
For your own work, you may find it nice to have CLion from JetBrains if you’re used to working in IntelliJ from CS61B. Note though that we won’t be providing any course-official support, so setting it up and maintaining it are up to you.
The majority of students do their work in a local editor (Sublime, Atom, VSCode) and use Git to copy their files from their local machine to the Hive. Some students also set up Cyberduck, Filezilla, or other SFTP programs to make editing remote files easier. Again, we can’t provide course-official support for every program under the sun, but you’re welcome to do what works best for you.
Tired of typing up an entire SSH command and password? 15 minutes could save you 15% of the time you spend on the comamnd line! Follow the instructions on this Piazza post (
"Useful additional setup information for labs and projects")