teaching machines

CS 330 Homework 0, Part 1

January 1, 2017 by . Filed under cs330, specifications, spring 2017.

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:

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.

Options for Installing 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:

You are welcome to pursue the first two routes, but you are on your own. We recommend setting up Linux under a virtual machine.

Virtual Machine

To install Ubuntu as a virtual machine image, 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.

Install Software

Now that you’ve got Linux up and running, 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.

Terminal

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.

Git

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.

ZSH

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 close the terminal and restart Ubuntu. When you open the terminal again, hit 2 to set up a default configuration in file ~/.zshrc.

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 <Up> and <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 .zshrc:

source ~/.zshrc

CMake

Some of the grading scripts 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