CS 352 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.
  • Running tools with a graphical user interface is much simpler when you aren’t logged into a remote server.

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.

Install Linux

You have a couple of options for installing Linux: install it on a bootable USB drive, or install it as a virtual machine image. Both options have their merits. Linux running off a USB drive feels a little more authentic and snappier without the virtual layer, while Linux running off a virtual machine image allows you to run both Linux and your host operating system at the same time.

Bootable USB Drive

Several people have reported trouble with this route, and I can no longer recommend it. If you pursue this route—at your own peril—and get it working, let me know!

To install Ubuntu on a USB drive, first find a USB drive with a capacity of at least 8 GB. Then download UNetbootin.

Choose Ubuntu for the distribution and Live_64 for the version. Select your USB drive.

In order for your changes (like software installations and configuration) to persist across boots, you must enter a number for Space used to preserve files across reboots. Something between 2-4 GB (2048-4096 MB) should be reasonable.

Once the installation is complete, restart your computer and perform whatever BIOS magic you need to perform to boot from your USB drive.

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.

Set Up 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.

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

Comments

  1. Hey Chris, will we be talking more about this in class on Friday?

  2. Haha didn’t mean to make my name my website that was silly.

  3. Aaron Nelson says:

    Important to know is that your instructor will require ZSH to run the spec checker in the next post. I run Arch, and it said “/usr/bin/env: ‘zsh’: No such file or directory”

Leave a Reply

Your email address will not be published. Required fields are marked *