All programming assignments must compile and run on 32-bit Ubuntu 16.04. To minimize the chance of hardware incompatibility, the best way to run Ubuntu Linux is to first install a virtual machine hypervisor (Oracle VirtualBox is recommended because it's free and available on both Windows and Mac OS X machines), then install 32-bit Ubuntu 16.04 into a virtual machine inside the hypervisor. This web page contains instructions on how to first install a virtual machine hypervisor (Oracle VirtualBox in particular) into your desktop/laptop, and then install 32-bit Ubuntu 16.04 into a virtual machine running inside the virtual machine hypervisor.

You need a machine that runs a real desktop operating system, such as Windows 10 or Mac OS X. If you can only get your hands on a machine that runs Android/iOS/ChromeOS or Windows 8 or something even older, please talk to the instructor before proceeding. (If you are considering buying a machine for school, it's best that you buy a machine that runs Windows 10 or Mac OS X.)

The minimum hardware requirement for running a virtual machine hypervisor is that you should have an Intel Core i3 or faster processor with 4GB or more memory. If your laptop/desktop has a slower CPU, non-Intel compatible CPU, or less than 4GB memory, please talk to the instructor before proceeding.

We can ONLY grade your programming assignments on a 32-bit Ubuntu 16.04 machine running QEMU 2.5. (Furthermore, the kernel assignments are ONLY known to work properly on 32-bit Ubuntu 16.04.) Therefore, you MUST implement and test your programming assignments on this platform. If you don't want to install Ubuntu 16.04 on your machine because you already have another version of Ubuntu installed, please or talk to the instructor before proceeding. If you choose to implement and test your programming assignments on something other than a 32-bit Ubuntu 16.04, you may end up getting zeroes in your programming assignments since the graders are not allowed to grade your assignments on other platforms!

Ubuntu 16.04 is not the current release of Ubuntu. If you just go to the Ubuntu web site, you will be downloading the WRONG version of Ubuntu. To download Ubuntu 16.04, you need to go to the Ubuntu 16.04 (Xenial Xerus) web site and download the desktop release of Ubuntu 16.04. We strongly encourage you to use the 32-bit Ubuntu 16.04 since all examples used in class will assume that your CPU is a 32-bit CPU. At the time of this writing, the file you should be downloading is "ubuntu-16.04.6-desktop-i386.iso". We will use this file name here. The important part of the file name is "16.04". The number after "16.04" is a release number and anything ≥ 4 would be fine. Please replaces all references to "ubuntu-16.04.6-desktop-i386.iso" with the file name of the ".iso" file you actually downloaded.

If you are running Windows 10 and your machine supports "virtualization" in BIOS, although it's not required, it's probably a good idea to have it enabled so things can run faster. If you don't know how to do that or check if you machine supports virtualization, just google "Enable virtualization in BIOS in Windows 10".

Please do NOT use Ubuntu 17.04 or above to do our programming assignments. The graders are not permitted to grade your programming assignments on those systems. I also know for sure that our kernel assignments are NOT compatible with Ubuntu 17.04 or above. You should definitely NOT use Ubuntu 17.04 or above to do our kernel assignments.

The only virtual machine hypervisor platform that I would recommend is the Oracle VirtualBox. Oracle VirtualBox is free and runs well on both Windows 10 and Mac OS X. (I was told that it also runs on a Linux machine, although I have never tried it myself.)

There may be other ways to install Ubuntu 16.04 so you can do your programming assignments. In the interest of time, we will only present one solution for everyone. If you are thinking about doing it in a different way, please talk to the instructor before proceeding to see if it's going to acceptable. The goal is for students to do the programming assignments. I really don't want students to waste time on system issues because that's not what this class is about.

Below are my instructions on how to install VirtualBox and then how to install Ubuntu 16.04 in side VirtualBox. Please understand that I cannot keep track of all the latest changes in VirtualBox and Ubuntu 16.04. Therefore, please do not be surprised if things don't look exactly the same as the figures or text on this web page. If you have questions, please feel free to send e-mail to the instructor.

Installing VirtualBox should be pretty straight-forward. Point your web browser to the VirtualBox Download Page. Please note that VirtualBox 6.0.0 seems to have problem with the display on Mac OS X. Therefore, if you are running Mac OS X, I would recommend that you download VirtualBox 5.2 instead (latest version would be fine). Click and download VirtualBox for the type of machine/host you have and follow the on-screen instructions to install VirtualBox onto your machine. (The terminology is that if you are running Windows 10, you have a Windows Host; if you are running on Mac OS X, you have a Mac Host.) Below are the typical steps you will see. It may be the case that you are not seeing the same screens since our machines may not be configured the same way. You should typically stick with the defaults, unless you are very familiar with VirtualBox know what you are doing.
  1. Welcome screen: just click on the Next button.
  2. Custom Setup screen (select features): just click on the Next button.
  3. Custom Setup screen (choose options): just click on the Next button.
  4. Warning about Network Interfaces screen: just click on the Yes button.
  5. Ready to Install screen: just click on the Install button.
  6. If you get a screen asking you about permissions, please give permission to install VirtualBox.
  7. Installation Complete screen: just click on the Finish button.
The next thing to do is to install Ubuntu 16.04 into VirtualBox.

Just want to mention that there is a way to run Ubuntu 16.04 in VirtualBox "headless" (i.e., no a desktop interface). If you are not an expert in running Linux, this would not be a good option. But if you are a Linux expert and you do not need a desktop interface, you can skip the section below and proceed to install VagrantBox (Vagrant with VirtualBox).

When you are done with installing VirtualBox, your machine would launch VirtualBox automatically and you will get a screen that looks like the following:
If you click con About VirtualBox under the Help Menu, you will see the version of the VirtualBox you are running. The screenshots here are from VirtualBox-5.2.22. If you are using a newer version of VirtualBox, your screens may look different.

Step 1: Create An Empty Virtual Machine

To install Ubuntu 16.04 into VirtualBox, first you need to create an empty virtual machine. Start with the above screen, if you click on the New button in the left-top corner and you should see the following screen:
Enter "u32-16.04.6" in the Name textbox (to mean "ubuntu", "32-bit", "version 16.04", and "release4"). (Please ignore my typo! Instead of "u32", I have "u34" in all the screenshots! Also, if you are installing version 16.04.6, you should name it "u32-16.04.6".) Select "Linux" as Type and select "Ubuntu (32-bit)" as Version, then click on the Next button. You should then see the following screen:
The default memory size is shown as 1GB and that's plenty if you just want to do your programming assignments! You should run as few applications inside your 32-bit Ubuntu 16.04 as possible and only use it to do your programming assignments. If you want to play around with Ubuntu 16.04, you can install another virtual machine. But you should keep this virtual machine lean and clean! You should definitely try to avoid running things like a web browser or a music player in this virtual machine.

If you have to run a web browser inside this virtual machine and you have 8GB or more memory in your host machine (Windows 10 or Mac OS X), you should increase the memory for this virtual machine to 2BG. (A web browser is a memory hog!) Please do NOT set the memory size to anything more than 2GB because the more memory you give to Ubuntu 16.04, the less memory the rest of your machine has. In general, you should run memory intensive applications inside your host machine and not inside a virtual machine.

After you set your memory size and click on the Next button, you should see the following screen:

Don't change a thing and click on the Create button, you should see the following screen:
Don't change a thing and click on the Next button, you should see the following screen:
Don't change a thing and click on the Next button, you should see the following screen:
Since the goal here is to work on your programming assignments, 10GB of disk space is plenty. Just click on the Create button, you should see the following screen:

Step 2: Setup The Virtual Machine

Start with the above screen, if you click on the Settings button near the left-top corner and you should see the following screen:
You can see that General is selected on the left and the Basic tab is selected in the right pane. We should see that under the Basic tab, we are setting up the virtual machine that we set out to build (Name being "u32-16.04.6"), Type being "Linux", and Version "Ubuntu (32-bit)"). If your Version is "Ubuntu (64-bit)", please change it to "Ubuntu (32-bit)". Select the Advanced tab and you should see the following screen:
Change the Shared Clipboard from "Disabled" to "Bidirectional" so that you can use the clipboard to copy from something running in the host and paste into something running inside the virtual machine or copy from something running inside the virthal machine and paste into something running in the host.

Click on Display on the left and you should see the following screen:

You should see that the "Enable 3D Acceleration" checkbox is not checked. Make sure you click on it to enable 3D acceleration. If you don't check this checkbox, your Ubuntu 16.04 will run very slowly.

Click on Storage on the left and you should see the following screen:

In the middle of the screen, inside a box that says "Storage Devices", there is a line that says "Controller: IDE". Right below it, it shows an icon of an optical disk with the word "Empty" right next to it. Click on the optical disk icon or "Empty" and you should see the following screen:
In the right column, for "Optional Drive", it's showing "IDE Secondary Master". There is another icon of an optical disk immediately to the right of it. Click on that icon (and not the "IDE Scondary Master") and you should get a popup menu that looks like the following:
Click on "Choose Virtual Optical Disk File" and navigate to the directory where you have downloaded the "ubuntu-16.04.6-desktop-i386.iso" file. Select the "ubuntu-16.04.6-desktop-i386.iso" file and you should see the following screen:
Notice that in the middle of the screen and right below "Controller: IDE", the previously "Empty" optical disk now becomes "ubuntu-16.04.6-desktop-i386.iso". (The "i386" in "ubuntu-16.04.6-desktop-i386.iso" means that it's a 32-bit system. If you see "amd64" and not "i386", please download and select "ubuntu-16.04.6-desktop-i386.iso" instead.)

[BC: paragraph added 5/18/2019]
Click on Audio on the left and make sure that the "Enable Audio" checkbox is NOT checked. This is very important! If you enable audio, your CPU usage may go to 100% and your system may crash or become unusable. Please ONLY use this system for doing your CS 402 programming assignments! Please do not use it for any type of entertainment!

Click on Shared Folders on the left and you should see the following screen:

A Shared Folder allows your Ubuntu 16.04 to exchanged files with host machine. On the right edge of the screen, there's an icon of a folder with a green plus sign on it. Click on it and you should see the following screen:
Immediately to the right of "Folder Path", there is an empty drop-down list. You are suppose to select a directory path for the Shared Folder. On a Windows 10 or Mac OS X host, I would now create a folder on the desktop and name the folder, "Shared-ubuntu". Then I would click on the empty drop-down list and get the following screen:
Click on "Other" and navigate to the "Shared-ubuntu" folder on the desktop and select it. You should see the following screen (of course, if your name is not "Bill", your Folder Path should show something else):
Please notice that the "Folder Name" is shown to be "Shared-ubuntu". This string is important when you setup your Ubuntu 16.04.

Check the Auto-mount checkbox and click on the OK button to finish setting up the Shared Folder. Your screen should look something like the following:

Finally, click on the OK button and you are done with setting up the virtual machine. Now you are ready to run your virtual machine for the first time.

Step 3: Run Virtual Machine For The First Time

Your screen should now look like what it was at the end of Step 1.

To run the virtual machine for the first time, select the Ubuntu 16.04 virtual machine on the left click on the Start button (which is to the right of the Settings button). A separate application window will be popped up that looks like the following (it may take up to a minute or so before the screen will look like the following, so be patient):

You should resize the application window (or maximize it) so that you can see the entire Installation screen inside the virtual machine and have it look like this:
Now click on the big Install Ubuntu on the right and you should see the following screen:
Please do NOT change the networking setting in the right-top corner of the window! Right now it's showing two arrows, one points up and one points down. This means that you are using a "wired Internet connection". Some people would think that since they are connected to the Internet via a wireless connection, they should change it to a wireless Internet connection. Please do not do that! You are inside a virtual machine. The Internet connection is a virtual/fake connection! Keep it that way so that your virtual machine will automatically use the Internet connection of your host machine indirectly. That's the best way!

Check the "Download updates while install Ubuntu" checkbox and click on the Continue button. (Please do NOT check the "Install third-party software" checkbox because you should keep this virtual machine as lean and mean as possible and use it only to do your programming assignments!) You should see the following screen:

Don't change a thing and click on the Install Now button to erase the "virtual disk" inside the virtual machine and install Ubuntu 16.04 into this newly erased "virtual disk". You should see the following screen:
Since we are installing Ubuntu 16.04 into a newly erased "virtual disk", it's perfectly okay to proceed. Click on the Continue button and wait a few seconds and you should see the following screen:
Keep the timezone in "Los Angeles" and click on the Continue button and you should see the following screen:
Select your keyboard and click on the Continue button and you should see the following screen:
This is a very important screen! So, please set it up carefully or you may have to redo everything from scratch.

Enter your name in the first textbox and come up with a name for your "virtual" computer. Under username, I would STRONGLY suggest that you use "local-part" of your USC E-mail address. (i.e., your USC e-mail address without the "@usc.edu") AND use the same password you used to ssh to nunki. This way, you will never forget what they are and this can make your life a lot easier! Please note that this password will also be your "Admin Password". Any time when you are running Ubuntu 16.04 and you are prompted for an "Admin Password", please enter this password. Again, using your password for logging into nunki.usc.edu here would mean that you have one less password to memorize.

Click on "Log in automatically" (since this is not a real machine) and click on the Continue button. After you clicked on the Continue button, Ubuntu 16.04 starts to get installed into the virtual machine and this can take a long time (anywhere from 15 minutes to half an hour, depending on the speed of your machine). When installation is eventually finished, your will see the following screen:

Click on the "Restart Now" button to finish the installtion. After a few seconds, you may see the following screen:
Click anywhere inside the window (your pointer may disappear and that's perfectly fine) and press <ENTER> and the virtual machine should restart. When the virtual machine finished restarting, Ubuntu 16.04 should be running and you should see the following screen:
If the above screen does not show up, please note the problem and scroll all the way to the bottom of this web page and try to match what you see with the items there and follow the steps to fix your problem. You may have to delete Ubuntu 16.04 and reinstall it from scratch.

The panel of buttons on the left is known as the "Launcher".

  • The first button is the Desktop Search button that can be used to look for installed application.
  • The 2nd button is for launching the Firefox web browser.
  • The 3rd button is for launching LibreOffice Writer (i.e., "Word for Linux"). You should remove this icon.
  • The 4th button is for launching LibreOffice Calc (i.e., "Excel for Linux"). You should remove this icon.
  • The 5th button is for launching LibreOffice Impress (i.e., "PowerPoint for Linux"). You should remove this icon.
  • The 6th button is for launching the Software Center program which is used to download and install new software. You should AVOID using this button because you may unintentionally make this system incompatible with our programming assignments and you will have to delete everything and reinstall Ubuntu 16.04.
  • The 7th button is for launching the Amazon app. You should remove this icon.
  • The 8th button is for changin your system settings.
  • The 9th button is for updating your system. This button may not appear at first. You may see this button appearing once in a while when you need to update your system. You should AVOID using this button because you may unintentionally make this system incompatible with our programming assignments and you will have to delete everything (remember to backup all your work) and reinstall Ubuntu 16.04.
Since we are setting up this machine for the sole purpose of doing the programming assignments, please remove LibreOffice Writer, LibreOffice Calc, LibreOffice Impress, and Amazon from the Launcher by right-clicking on the icon and select "Unlock from Launcher".

Step 4: Run Ubuntu 16.04 For The First Time

The first thing you should do is to disable the screen lock so that you don't have to be entering your password all the time. The reason you don't need screen lock is that you are running inside a virtual machine. If your host machnie's laptop/desktop is locked, you don't have to worry about the virtual machine inside. Please click on the Settings icon in the Launcher to setup your desktop. Your screen should look like the following:
Click on "Brightness & Lock" and you should see the following screen:
Change "5 minutes" to "Never" and click on Lock to turn screen lock off and your screen should look like the following:
Click on the close box in the left-top corner of the "Brightness & Lock" window to finish up "Settings".

The next thing you should do is to add the Terminal program to the Launcher. (The actual name for the Terminal program is the "gnome-terminal".) Move the pointer to the first icon in the Launcher and click on it. Then type "Terminal" and your screen should look like the following:

Click on the icon for the Terminal program to run it. Your screen should look like the following:
You should keep the Terminal icon in the Launcher so you don't have to search for it over and over again. Right-click on the Terminal icon in the Launcher and select "Lock to Launcher".

Step 5: Install Guest Additions

If you try to copy some text from an application running in the host (such as a web browser) and paste into the Terminal, you will notice that it does not work! Also, some systems (especially on the Mac) can exhibit performance problems at this point or the display may not resize properly. You need to do the following now. Select "Insert Guest Additions CD Image..." from the Devices Menu in the outer-most window (greyed out in the above screenshot) and your screen should look like the following:
Click on the Run button and you will be prompted for your admin password. Enter your admin password and click on the Authenticate button and the Guest Additions will start to install. This can take several minutes. When it's done, your screen can look like the following:
Please notice that in the above screen, there is an error reported:
    VirtualBox Guest Additions: modprobe vboxsf failed
So, we are not done yet. As it turned out, this probably will automatically get fixed after we reboot the system. For now, just press <ENTER> and the 2nd Terminal window should close.

In case you did not see the dialogbox with the Run button in the first image above, but got an error message instead. You should close the error message dialogbox and type "df" in the Terminal window. If you see a line that looks something like the following (doesn't have to be an exact match):

    /dev/sr0           56618   56618         0 100% /media/SOMETHING/VBox_GAs_5.2.22
you should type the following in the Terminal window to install the Guest Additions:
    cd /media/SOMETHING/VBox_GAs_5.2.22
    sudo ./VBoxLinuxAdditions.run
If you are prompted for your admin password, just type it and press <ENTER> to proceed.

At this point, it's probably a good idea to reboot the system so you can use copy and paste to copy commands from the web browser and paste into a Terminal. Go ahead and reboot the system then proceed with the next step.

Step 6: System Update

The Terminal program runs a Shell Program (sometimes referred to as the Login Shell). A Shell Program has a text-based, commandline user interface for you to enter Linux commands. In the above screenshot, the text in green is the commandline prompt. Yours will most likely be different from mime. From the commandline, you can perform a bunch of important tasks. Please see the Linux Shell section below for some of the commands you will need to run. The first thing you should do is to update your system by running the following commands in the Terminal:
    sudo apt-get -y update
    sudo apt-get -y dist-upgrade
    sudo apt-get -y upgrade
These commands can take 15 to 30 minutes to finish. Sometimes, it takes so long that you will be prompted for your admin password for the second time.

Please note that the above 3 commands contain the word "upgrade". This particular "upgrade" is not to upgrade Ubuntu 16.04 to a different version of Ubuntu, but to "upgrade" only within current distribution. The above 3 commands is the only way you should "upgrade" the system. Please do not "upgrade" your system using any other method!

This should be the ONLY time you need to update your system. For the rest of the semester, even if you are offered to update your system, you should NOT accept to update your system! If you update your system, you may unintentionally make your system incompatible with our programming assignments and you will have to delete everything (remember to backup all your work) and reinstall Ubuntu 16.04.

The "apt-get" is the program for downloading and installing a piece of software. But only administrator can install software. Although you are an administrator on your own machine, you do not run at the administrator privilege level by default. The "sudo" command is used to temporarily raise you security privilege to the level of an administrator in order to execute the rest of the command you typed into the commandline. Therefore, when you run the above command, you will be prompted to enter your admin password before the rest of the command can be executed. The good news is that if you run the sudo command subsequently in the same console, you will not be prompted to enter your password, unless your console has been idle for some time.

Please note that you can only run one instance of apt-get at a time. Internally, the Software Center also invokes apt-get to download and install software. So, if the Software Center is busy installing a program, you will be blocked from running apt-get until the Software Center is finished.

Step 7: Install Software for Kernel Assignments

You should also install all the programs that's needed to do your programming assignments now. Please enter the following commands into the Terminal:
    sudo apt-get install -y tcsh vim dos2unix tmux valgrind git gitk git-core qemu cscope xorriso

Step 8: Reboot

After you are done with the above, one final thing to consider is whether you want to change your default Linux Shell or not. When you are done with that, you should reboot your system.

If you look at the last screenshot, in the right-top corner of the Ubuntu 16.04 system, immediately to the right of the current time is the System Menu. If you click on it, you can see that the last item in the menu is "Shut Down". Select Shut Down there and you will get a choice of either restarting the system or shutdown the system. If you click on the big Restart button on the left, the system would reboot. You can also click on the big Shut Down button on the right instead. Ubuntu 16.04 will shutdown and the virtual machine will also shut down. To run Ubuntu 16.04 again, you need to go back to the VirtualBox application (see the screenshot above), select this particular virtual machine and click on the Start button. (If you have setup everything correctly, you should never have to click on the Settings button ever again!)

After the system is restarted, start a Terminal window. Inside the Terminal, type the following:

    df
and your screen should look like the following:
What's important to notice above is that there is a file system called "Shared-ubuntu" which is the Shared Folder that you have created a while back! (Recall that there was an error because the system needs to be restarted. Now that the system has been restarted, Shared Folder should work now.) This file system is shown to be "mounted" on /media/sf_Shared-ubuntu to mean that it can be accessed by referring to /media/sf_Shared-ubuntu. Unfortunately, you cannot use it like this since it can only be accessed from the admin account. To make it accessible by you, you should do the following in a Terminal:
    sudo sed -i "1,$$s/vboxsf:x:998:/&${USER}/" /etc/group
    sudo sed -i "1,$$s/vboxsf:x:999:/&${USER}/" /etc/group
    cd
    rm Shared-ubuntu
    ln -s /media/sf_Shared-ubuntu Shared-ubuntu
The above commands add yourself to the access list for the Shared Folder and also create a "symbolic link" so that you can reach the shared folder using the "Shared-ubuntu" directory in your home directory.

Please note that on some systems, instead of seeing "/media/sf_Shared-ubuntu", you may see "/Shared-ubuntu". If that's the case, please reaplce "/media/sf_Shared-ubuntu" with "/Shared-ubuntu" above.

Try the following:

    cd
    cd Shared-ubuntu
    echo "Hello World!" > hello.txt
Then go to your host machine and click open the Shared-ubuntu folder on your desktop and see if you can open the hello.txt file in it.

Since the system has been restarted, bidirectional copy and paste between Ubuntu 16.04 and the host system should work. So, instead of typing all the text above, you can just highlight them in your browser and press <Cntrl+C> on Windows (or <Cmd+C> on the Mac) to copy the highlighted text into the shared bidirectional clipboard and click on a Terminal in Ubuntu 16.04 and press <Cntrl+Shift+V> to paste it into the commandline. This should save you a lot of typing and is also less error-prone! (If you want to copy and paste in the reverse direction, say to e-mail some text you see in a Terminal to me, you can highlight some text in a Terminal, press <Cntrl+Shift+C> to copy the highlighted text into the shared bidirectional clipboard and click on an application running in the host system (such as an e-mail app running in a web browser) and press <Cntrl+V> on Windows (or <Cmd+V> on the Mac) to paste the text into your e-mail app.)

Now you are all setup to use Ubuntu 16.04!

If you are not an expert in running Linux without a desktop, this is not for you! But if you are a Linux expert and you do not need a desktop interface to use Linux, you can install something call Vagrant to run a "headless" (i.e., desktop-less) Ubuntu 16.04 system. Vagrant can work with various virtual machine hypervisors. For this class, please only use it with the Oracle VirtualBox.

Although Vagrant does not have a desktop, you may still need to run programs that has a graphical user interface (such as our kernel assignments). In order to be able to run those programs, you need to run an X11 Window Server. If your system is an Mac OS X system, please download and install XQuartz before proceeding. If your system is running Window 10, please install Cygwin before proceeding. The installation steps are very similar between Mac OS X and Windows 10. The only difference is that you will be running a Cygwin Terminal if you are running Window 10 and you will be running a XQuartz Terminal (i.e., a program with "xterm" in the titlebar).

Here are the steps.

  1. Follow the instructions above to install VirtualBox. (VirtualBox 6.0 has just came out and I don't think it's compatible with Vagrant. Please install VirtualBox 5.2 for now if you want to run Vagrant.) Do not install Ubuntu 16.04 into VirtualBox, yet.
  2. Point your web browser to the Vagrant Start Page and click on the big Download button in the middle of the screen which will take you to the "Download Vagrant" page. If your machine is a 64-bit machine, download and install the 64-bit version of these software. Click and download Vagrant for the type of machine/host you have and follow the on-screen instructions to install Vagrant onto your machine.
    1. Welcome screen: just click on the Next button.
    2. License screen: check the "I accept" checkbox and click on the Next button.
    3. Destination Folder screen: just click on the Next button.
    4. Ready to Install screen: just click on the Install button.
    5. If you get a screen asking you about permissions, please give permission to install Vagrant.
    6. Installation Complete screen: just click on the Finish button.
    After Vagrant is installed, on Windows 10, you will get a popup box saying that you need to restart Windows. If you want to continue with the steps below, you should restart Windows.
  3. If your system is an Mac OS X system, run XQuartz.app from the Utilities folder in Applications. You should get a window with "xterm" in the titlebar. To setup for copy and paste inside xterm, please select Preferences from the XQuartz menu, select the Input tab and check the "Emulate three button mouse" checkbox. Once you have done this, you can paste into "xterm" by holding down the <Option> key and click on the mouse button. If your system is running Window 10, start a Cygwin64 Terminal. We will simply refer to either the XQuartz terminal or the Cywgin64 terminal as the "Cygwin/XQuartz terminal".
  4. In the Cygwin/XQuartz terminal, run the following commands:
        mkdir ~/Vagrant16
        mkdir ~/Vagrant16/sitepoint
        mkdir ~/Vagrant16/shared-ubuntu-vagrant
        pushd ~/Vagrant16/sitepoint
        vagrant init
        rm Vagrantfile 
        vagrant init ubuntu/xenial32
        mv -f Vagrantfile Vagrantfile.$$
        sed -e '/synced_folder/s/# config/config/' Vagrantfile.$$ > Vagrantfile
        mv -f Vagrantfile Vagrantfile.$$
        sed -e '/synced_folder/s/data/shared-ubuntu-vagrant/' Vagrantfile.$$ > Vagrantfile
        vagrant up
        popd
    At this point, the VagrantBox has been installed. A superuser account inside the VagrantBox has been setup. The account's user ID is "vagrant" and the password is also "vagrant". If everything works the way they suppose to, you should be able to use the following command to ssh into the VagrantBox:
        ssh -X -Y vagrant@127.0.0.1 -p2222
    Please give the above command a try first (and use "vagrant" as password). If that works, fantastic, and you can skip the next step. Otherwise, it means that there is a bug in the "ubuntu/xenial32" box (i.e., for 32-bit Ubuntu 16.04). In this case, please follow the instructions in the next step to setup a separate account so you can ssh into the VagrantBox.
  5. This step is only required if you cannot ssh into the VagrantBox using "vagrant" as password. Here's what you need to do. Firstly, you need to shutdown the VagrantBox from the Cygwin/XQuartz terminal:
        pushd ~/Vagrant16/sitepoint
        vagrant halt
        popd
    Find VirtualBox on your desktop, double click to launch it. (If you are running Windows 10 Professional and you know the admin password, you should right-click on VirtualBox and select "Run As Administrator".) It should look like the following:
    The virtual machine named "sitepoint_default_..." is the one you have just installed. Make sure it says "Powered Off". If it doesn't say that, you did not halt the VagrantBox and you should run the command above.

    Select the virtual machine you have just installed and click on the green Start button to run Ubuntu 16.04 in a separate window. Since this Ubuntu 16.04 does not have a desktop, it will look like the following after it's up and running:

    Please note that the lower right corner of the screen says Right Ctrl. If for some reason you cannot move your pointer out of the Ubuntu 16.04 virtual machine, you need to press the <Cntrl> key on the right side of your keyboard to "un-trap" your pointer.

    Type "vagrant" as your login ID and "vagrant" as your password and you should be able to login. Your screen should now look like the following:

    Unfortunately, copy and paste doesn't work because there is no desktop. So, you have to type the following into the Ubuntu 16.04 screen.

    Let YOURLOGIN be your nunki.usc.edu login ID. and YOURNAME be your name. Type the following into the Ubuntu 16.04:

        export ID=YOURLOGIN
        sudo mkdir /home/$ID
        sudo groupadd -g 500 $ID
        sudo useradd -u 500 -g 500 -d /home/$ID -s /bin/bash -c "YOURNAME" $ID
        sudo passwd $ID
        sudo chown -R $ID /home/$ID
        sudo chgrp -R $ID /home/$ID
        sudo usermod -aG sudo $ID
        exit
    The "sudo passwd" command asks you to setup a password for this account. I would suggest that you use the same password as your nunki.usc.edu login. This way, you won't have to remember additional passwords.

    After you have entered the above commands, you should see the same login screen as before. Now login with your own user ID and password that you have just setup. If you cannot login, it means that you have made a typo. Then you need to repeat the setup procedure. But before you do that you must delete your account by doing the following by logging into the vagrant account and do the following:

        export ID=YOURLOGIN
        sudo userdel $ID
        sudo rm -rf /home/$ID
    Now you have a logged in using your own account, you need to generate a public key so you can ssh into your VagrantBox. Please do the following:
        ssh-keygen
    This program will generate a public key. It will ask you several questions and you must give the following responses:

    • Just press <ENTER> to the first question and use the default file name and location.
    • Enter the password of your own account.

    You need to copy the public key file into your Cygwin/XQuartz account. The easiest way is to do a file transfer via nunki.usc.edu. Please do the following:
        cd .ssh
        ln -s ../Vagrant16/sitepoint/.vagrant/machines/default/virtualbox/private_key private_key
        mv id_rsa.pub authorized_keys
        mv id_rsa id_vagrant16_rsa
        scp id_vagrant16_rsa YOURLOGIN@nunki.usc.edu:id_vagrant16_rsa
        sudo halt
    When you run the scp command above, it may ask you if you want to continue, type "yes" and press <ENTER> to proceed. The last command shuts down the VagrantBox. Your screen should look like the following:
    Now select Close from the File Menu and you will see the following screen:
    Select "Power off the machine" and click on the OK button to turn off the virtual machine. Now your VirtualBox should look the same as what it looked like at the beginning of this step (i.e., it should say "Powered Off"). Now you can also quit VirtualBox by selecting Exit from the File Menu.

    There is one more thing to do is to copy the id_vagrant16_rsa file from your nunki.usc.edu account into your Cygwin's (or XQuartz's) "~/.ssh" directory. Please do the following in your Cygwin/XQuartz terminal"

        cd ~/.ssh
        scp YOURLOGIN@nunki.usc.edu:id_vagrant16_rsa id_vagrant16_rsa
    Now you are all set to use your account in the VagrantBox. Bring up your VagrantBox using the following commands:
        pushd ~/Vagrant16/sitepoint
        vagrant up
        popd
  6. If you were able to ssh to your VagrantBox without doing Step 5 above, you should use one of the following commands to ssh to the "vagrant" account inside your VagrantBox from now on:
        ssh -X -Y vagrant@127.0.0.1 -p2222
    or (the following is more likely to work):
        ssh -X -Y -i ~/.ssh/private_key vagrant@127.0.0.1 -p2222
    If you don't want to use the "vagrant" account but want to use the account you have setup for yourself (in Step 5 above), you will need to use the following command to ssh to your VagrantBox from now on:
        ssh -X -Y -i ~/.ssh/id_vagrant16_rsa YOURLOGIN@127.0.0.1 -p2222
    I will refer to either of these two commands as your vagrant-ssh command from now on.
  7. Use your vagrant-ssh command to ssh to your VagrantBox. Since your Ubuntu 16.04 is only a barebone system, you need to install all the needed packages. Please run the following commands:
        sudo apt-get -y update
        sudo apt-get -y dist-upgrade
        sudo apt-get -y upgrade
        sudo apt-get install -y tcsh
        sudo apt-get install -y vim dos2unix tmux valgrind git gitk git-core
        sudo apt-get install -y zip gdb libssl-dev xorg gnome-terminal xterm evince libreoffice
    By default /bin/bash is your Login Shell. If you would prefer to use /bin/tcsh as your Login Shell, you need to run the chsh command above and enter "/bin/tcsh" as your new shell. If you are fine with /bin/bash as your Login Shell, you don't need to run the chsh command.

    The last command above will install a lot of software packages and can take something like 15-20 minutes to complete.

  8. Follow the above instruction to install all the necessary software to do your programming assignments.
  9. Type "exit" to disconnect from your Vagrant Box. From this point on, you should not be use "vagrant ssh" command to connect to your Vagrant Box any more because these is no way to run an application that needs to create a window on your screen. One such application is QEMU. What you need is either X-Win32 or Cygwin to be able to connect to your Vagrant Box and for your Vagrant Box to connect back to your display.
  10. If you want to turn off the Vagrant Box, type "vagrant halt" in the Cygwin/XQuartz terminal.
A Linux Shell program runs inside a Terminal program. By default, your Linux Shell is bash. If you want your login shell to be tcsh, you can simply type "tcsh" (assuming that you have installed it already). If you want to change your default login shell, please do the following in a Terminal:
    chsh
You will be prompted for your admin password, again. Then enter:
    /bin/tcsh
After you have rebooted your system, your terminal will be running the new login shell.

It is imperative that your group uses a version management system. The software of choice is Git, originally designed and written by Linus Torvalds.

If you are not familiar with Git, please read the free online book, Pro Git, mentioned in the textbooks section of our course description web page.

There are free web sites on the Internet that provide free Git repository service. You should be able to create an account there and share it along your team members. Please make sure that your code is private so that no one other than your team members can see or change the code. Please note that if others (such as the teaching staff) can see your code repository (because it is not private), it will be considered cheating and there are serious consequences. As I have mentioned in the first lecture, you do not have the right to display your assignment-related code in public (even if your prospective employer asks you to). If you display your assignment-related code in public in the middle of the semester, your group will get a zero for the assignment. (If others have cheated off of your code, then your case will be reported to the university and everyone in your group will end up failing the course.) If you display your assignment-related code in public after the semester is over, I will ask the university to change the grades of everyone in your team because you are helping future students cheat. (As I have mentioned in Lecture 1 that USC Student Conduct Code says that you must not knowingly allow other students to cheat from you.) So, please make double sure that your code repositories related to this class are all private.

Please do NOT use github.com becuase your private repository automatically turns into a public one if you do not pay them! To start using BitBucket, please visit the relevant part of the projects page.

Some students have reported that they had trouble installing Ubuntu 16.04 into VirtualBox. It does not mean that these systems won't work. I'm just keeping track of what people have seen here. It usually mean that the standard procedure may not work and you should try the suggestions in the "Solutions" column below to see what you need to do. If you have the same system and are experiencing the same problem, please send me an e-mail so I know the problem is wide spread. If you are having trouble getting Ubuntu 16.04 to work on a system that's not listed, please send me an e-mail so I can add it to the list.
System Description Solutions
Windows 10 Got a blank/black screen with a blinking cursor when running Ubuntu (or get a message saying that raw-mode in unavailable because of Hyper-V).
1)   Check to see if you are running Hyper-V (virtualization technology from Microsoft). VirtualBox is not compatible with Hyper-V. So, you should disable Hyper-V. (If you don't want to disable Hyper-V but install Ubuntu 16.04 into Hyper-V instead, you will be doing this at your own risk. Please understand that the grader must grade your programming assignments using Ubuntu 16.04 running in VirtualBox!)

Start Control Panel and search for "Turn Windows features on or off". If the Hyper-V checkbox is checked, then you are running Hyper-V. If you uncheck it, you would turn off Hyper-V and you should reboot the system and verify that Hyper-V has been turned off.

 
2)   If it turns out that you do not have Hyper-V enabled, you should try the following.

First, uncheck 3D acceleration.

Even though you are suppose to have 3D acceleration checked, but if there is a problem with the graphics device driver, you should disable 3D acceleration first, then after you are able to see things, go ahead and install Guest Additions so you get the right graphics device driver. Then you check 3D acceleration and see if it now works.

 
3)   Make sure you have virtualization enable in your BIOS (in UEFI settings). The steps for Windows 10 Home can be found here.
Mac OS X Switching or moving windows is slow inside VirtualBox
1)   Make sure you turn on 3-D acceleration.

Shutdown VirtualBox and restart it. Select Ubuntu but don't start it. Clickc on Settings and then Display and make sure the 3-D accelation checkbox is checked.

 
2)   If the above doesn't help and you haven't installed the VirtualBox Guest Additions, please make sure you install it.
Mac OS X Ubuntu desktop goes blank when Ubuntu is running or when I maximize the virtual machine window Try resizing the virtual machine window and see if you can see the Ubuntu desktop. If you are in full-screen mode, press <Cmd+F> to get out of full-screen mode and then resize the virtual machine window and see if you can start to see the Ubuntu desktop.

If the above works, it's probably because you are running VirtualBox 6.0.0 and it seems to have this bug on a Mac. I would suggest that you first uninstall/delete Ubuntu from this VirtualBox, then download and install VirtualBox 5.2 and then install Ubuntu into the new VirtualBox.

Mac OS X CPU usage goes to 100% when VirtualBox is running and the system become very slow and unusable You probably have audio enabled. Shutdown Ubuntu and go to the VirtualBox setup screen, click on Audio on the left and make sure the Enable Audio checkbox is unchecked.
Windows 10 Cannot see the button I need to click during installation During installation of the keyboard, the window you see may be too narrow that you cannot see the "Continue" button. When you can do is to press the <TAB> key on your keyboard and you should see that different part of the window got highlighted. Keep tabbing until you see the "Detect Keyboard Layout" button become highlighted. If you tab two more times, the "Continue" button will become highlighted (even though you may not see it because it's off to the right of the window). Just press the <ENTER> key and it would be the same as clicking the "Continue" button.

The screen after this screen has the same problem and you should do the same thing. After you have entered your information, keep pressing the <TAB> key until you see the "Back" button is highlighted (you won't see "Back", but you should check the image above to know where the "Back" button is. Once you are there, if you press the <TAB> key one more time and press the <ENTER> key, it would have the same effect as click the "Continue" button.

Windows 10 Wifi stopped working in Windows If you have something called Lavasoft Web Companion, it may have interfered with VirtualBox networking. Uninstalling Lavasoft Web Companion would fix the problem. Please see https://superuser.com/questions/1192452/networking-on-virtualbox-suddenly-stopped-working.