Although it's not recommended, but if you are a Linux/Unix expert and are comfortable with a commandline interface to Linux/Unix systems (i.e., without a desktop graphical user interface), you can also try VagrantBox (i.e., Vagrant with VirtualBox) and use it to do your programming assignments. But please understand that if you do your development in a VagrantBox, it's your responsibility to make sure that your code runs perfectly on a standard 32-bit Ubuntu 16.04 machine running inside VirtualBox since that's the only platform the grader is allowed to use for grading. 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 have 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/11. 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 to install VirtualBox. Please install VirtualBox 6.1.6 for now if you want to run Vagrant. (You should also try the more recent version of VirtualBox. The latest version I have tested on Windows was VirtualBox 7.0.18 and that seemed to work fine.) 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. (The latest version I have tested on Windows was with VirtualBox 7.0.18 was Vagrant 2.4.1 and that seemed to work fine.)
    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/11, 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 (on Windows 10/11, please do "tcsh" first and run all the command below under "tcsh"):
        mkdir ~/Vagrant16
        mkdir ~/Vagrant16/sitepoint
        mkdir ~/Vagrant16/shared-ubuntu-vagrant
        pushd ~/Vagrant16/sitepoint
        set path=('/cygdrive/c/Program Files/Vagrant/bin' $path)
        rehash
        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" (although you don't need to password to login via ssh). If everything works the way they suppose to, you should be able to use the following command to ssh into the VagrantBox:
        cd
        cd .ssh
        ln -s ../Vagrant16/sitepoint/.vagrant/machines/default/virtualbox/private_key vagrant_private_key
        ssh -X -Y -i ~/.ssh/vagrant_private_key vagrant@127.0.0.1 -p2222
  5. Now you are logged into the "vagrant" account in the VagrantBox. The next thing to do is to setup your own account inside the VagrantBox.

    Let YOURLOGIN be the "local-part" of your USC E-mail address (i.e., your USC e-mail address without the "@usc.edu") 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
        su - $ID
    The "sudo passwd" command asks you to setup a password for this account. I would suggest that you use the same password as your USC E-mail password. This way, you won't have to remember additional passwords.

    The last command take you from the "vagrant" into your own account. Please enter the password you just setup for your account.

    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 pair of public and private keys. 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 the "vagrant" account. Please do the following:
        cd .ssh
        mv id_rsa.pub authorized_keys
        mv id_rsa id_vagrant16_rsa
        tar cvf ~/secret.tar id_vagrant16_rsa
        exit
    Now you are back in the "vagrant" account. Please type the following:
        cd
        cp /home/$ID/secret.tar secret.tar
        exit
    The last command logs you out of the "vagrant" account from the VagrantBox and you are now back at the Cygwin/XQuartz account account. Please type the following:
        cd ~/.ssh
        scp -i ~/.ssh/vagrant_private_key -P 2222 vagrant@127.0.0.1:secret.tar secret.tar
        tar xvf secret.tar
        rm -f secret.tar
        ls -lrt
    You should see that you now have the "id_vagrant16_rsa" file and you are all set to use your account in the VagrantBox.
  6. From now on, to ssh into your account inside VagrantBox, do:
        ssh -X -Y -i ~/.ssh/id_vagrant16_rsa YOURLOGIN@127.0.0.1 -p2222
    I will refer to the above command 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 qemu cscope xorriso 
        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 few commands above will install a lot of software packages and can take something like 30 minutes to complete.

  8. Follow the instructions to install all the necessary software to do your programming assignments.
  9. Type "exit" to disconnect from your VagrantBox. From this point on, you should not be use "vagrant ssh" command to connect to your VagrantBox 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 VagrantBox and for your VagrantBox to connect back to your display.
  10. If you want to turn off the VagrantBox, type "vagrant halt" in the Cygwin/XQuartz terminal.