CS 330: Homework 0, Part 1
In this course, you will be completing your homework using the Linux operating system. The Department of Computer Science does provide some Linux servers that you can use, but your instructor asks you to install your own Linux image for a few reasons:
- You will learn more about a technology whose impact on our field is hard to overestimate.
- The departmental servers are not as fast and reliable as we’d like them to be, and they don’t support running graphical applications remotely.
If you already have a computer with Linux installed, feel free to use it. Follow the instructions here to get a copy of Ubuntu Linux up and running. You are free to use other Linux distributions, but your finite instructor will not be able to support it.
1. Install Linux
You have a couple of options for installing Linux: install it on your main disk drive, install it on a bootable USB drive, or install it as a virtual machine image. All options have their advantages and disadvantages:
- Linux running off disk feels most authentic and the performance is much snappier than the other approaches, but you must commit wholeheartedly to the OS or set up a dual booting environment.
- Linux running off a USB drive is portable and doesn’t require you to permanently muck with your computer, but many USB-based Linux installs don’t persist files across boots.
- Linux running off a cloud provider.
- Linux running off a virtual machine is straightforward to set up and doesn’t obliterate your host operating system, but the layer of virtualization can slow things down.
You are welcome to pursue the first two routes, but you are on your own to get them set up. I recommend setting up Linux through a cloud provider like Digital Ocean or under a virtual machine like Virtual Box. Over the past several semesters, students have consistently encountered mysterious filesystem issues with Git and Virtual Box. Not all students have been affected, but some. You may want to favor Digital Ocean.
Windows 10 also supports Linux, but there are too many incompatibilities. Do not use it. I refuse to help you if you are using the Windows Subsystem for Linux. We both have better things to do with our time.
Cloud Virtual Machine
Digital Ocean provides virtual machines in the cloud. They call them droplets. Normally, droplets cost money, but through the GitHub Student Developer Pack, you can get a $50 credit for Digital Ocean. This credit supports ten months of a $5/month droplet, long enough to get you through the semester without spending a penny.
Unfortunately, you will need to enter a credit card number on Digital Ocean, even though you won’t be spending any money for this course.
Follow these steps to get an effectively-free droplet:
- Create an account on Digital Ocean with your UWEC
.eduaddress. If you use me as a referral, you’ll get an additional $10 worth of credit. (Full disclosure: I receive $25 credit whenever someone I’ve referred spends $25. I do not expect you to pay any money to Digital Ocean. If you end up continuing with their service after your credit runs out, great. The credit I receive will support the hosting of my website.) If you want to bypass the referral, head to Digital Ocean directly.
- Request the GitHub Student Developer Pack. They will send you an email approval, eventually.
- Once approved, revisit GitHub’s page. Scroll down and copy the Digital Ocean promo code.
- In Digital Ocean, visit Settings / Billing and add your promo code. Verify that you received your $50 credit.
- On the Droplets page, click Create Droplet. Configure it in the following way:
- Image: Ubuntu 16.04
- Size/plan: $5/month
- Data center: in the US
- Hostname: something reasonable
- Using the IP address listed in the droplets table and the root password that was emailed to you, log in to your droplet with your favorite SSH client.
- Running as root is dangerous. Make a separate account that doesn’t automatically have administrator privileges with these commands:
adduser YOURUSERNAME usermod -aG sudo YOURUSERNAMEReplace
YOURUSERNAMEwith a username of your choice, preferrably in all lowercase letters. (But who am I to stop you?) The second command adds you to the “sudoers” group, which grants elevated privileges to any command prefixed by
Delete your droplet at the end of the semester to avoid charges.
Local Virtual Machine
To install a virtual machine running Ubuntu locally, you first need a virtual machine manager. Many exist. Your instructor is most familiar with Oracle’s VirtualBox and suggests using it. Download and install it on your personal computer.
Also download the latest version of Ubuntu.
Open VirtualBox and click New to create a new image. Name it as you wish, set Type to Linux, and ensure Version matches the version of Ubuntu that you downloaded. Click Continue.
If you have enough RAM in your computer, allocate 2 GB (2048 MB) to your virtual machine. Keep progressing through the setup dialogs, retaining the default values. When the setup is all done, select your virtual machine and click Start.
You will be prompted for an optical disk file. Navigate to the Ubuntu image that you downloaded earlier and hit Start.
After Ubuntu boots, you will be asked to install or try Ubuntu. Click Install Ubuntu and proceed through the setup dialogs. The default installation settings are reasonable. When you are asked about erasing the hard disk, do not be concerned about the safety of your computer. It will only erase the virtual hard disk that VirtualBox created for you.
Once the installation completes, restart the virtual machine and log in.
2. Install Software
Now that you’ve got Linux up and running, either locally or remotely, let’s set up and install some software that we’ll need for this course. This is a list of software that we will need throughout the semester. Individual homework assignments may require you to install additional software.
If you are running on Digital Ocean, you will be automatically dropped into a terminal by your SSH client.
If you are running through Virtual Box, a terminal application named GNOME Terminal is already installed. To find it, click on the top icon of the Launcher, the column of icons on the left side of the screen. Type terminal and open the first match. A terminal window appears. To make opening it easier in the future, right-click on its icon in the Launcher and select Lock to Launcher.
Your homework will be managed via a Git repository, which you will learn more about later. Install the Git client by entering the following in the terminal:
sudo apt-get install git
Text Editor or IDE
Your instructor strongly recommends that you use this course as an opportunity to learn a command-line text editor like Vim or Emacs. The advantage of doing so is that you will be able to work on remote machines that don’t have a graphical user interface, which makes you a more powerful computer scientist.
Install one or both with the following:
sudo apt-get install vim sudo apt-get install emacs
Find some tutorials to learn how to use these tools.
The program that process your commands in the terminal is called the shell. By default, the shell is bash. Your instructor prefers zsh because it makes a lot of tasks easier and has an unrivaled tab-completion system. You are free to stick with bash, but you must at least install it because the grading scripts rely on it:
sudo apt-get install zsh
If you wish to adopt it as your shell, run:
chsh -s /bin/zsh
The easiest way to effect this adoption is to disconnect or close the terminal and restart Ubuntu. When you open the terminal again, hit 2 to set up a default configuration in file
One of the most useful settings in your shell is to make it easy to bring up a past command by just typing its first few letters. Suppose you compiled some code 10 lines ago with
g++. You could hit
<Up> 10 times, or you could retype the command from scratch, or you could type
g+<Up>. Your instructor prefers the last of these.
To make quick recall of past command lines possible, open up
~/.zshrc in your favorite text editor and add this line somewhere:
bindkey "\e[A" history-beginning-search-backward bindkey "\e[B" history-beginning-search-forward bindkey "\eOA" history-beginning-search-backward bindkey "\eOB" history-beginning-search-forward
Different terminals handle control keys like
<Down> differently. Two common setups are covered by the lines above. Save and close the file. At the command-line, type the following to reload
The grading tools use the
curl utility to fetch files from the web. It’s installed automatically with Ubuntu. Verify its presence by running this command:
Some of the grading tools download helper packages like Google Test, a C++ testing framework from Google. These are built using CMake. Install it with:
sudo apt-get install cmake
3. Wipe Brow
There. Your own Linux is installed. If this is your first time doing this, you have become a much more powerful human being, but you may not feel any different.
Continue on to part 2.