Install Linux On Vagrant With VirtualBox - CSCI 353, Spring 2018

All your programming assignments must run on which is a Unix machine running Solaris or on a Ubuntu 14.04 or 16.04 machine running inside VMware/VirtualBox/VagrantBox. In order to get on, you need to ssh into it. Unfortunately, our ssh connection over the campus wireless network can be slow or unreliable. To save frustration, it may be better to develop your work on a Linux machine and occasionally copy your code to to make sure that your code works on both machines.

Please understand that Linux is not Solaris. Your code may work perfectly on Linux but fail to even compile on! Therefore, you must not assume that whatever that works on Linux will work on The only way to make sure is to do rigorous testing on, if you want to make sure that your code runs perfectly on nunki.

To minimize hardware incompatibility, the best way to run Linux is to install Linux into a virtual machine. This can be a lot of work. Fortunately, there is something called Vagrant that's not too difficult to install. (Although it may not be so easy to use if you are not familiar with the commandline interface of Linux/Unix since its desktop is hidden from you.) Vagrant can work with different virtual machine environments (some would call them "virtual machine containers"). We will use VirtualBox below since it's available for both Windows and Mac machines.

All examples below will assume that you have a 64-bit machine since it's more common these days. Although inside a virtual machine, we will run a 32-bit Linux system (Ubuntu 14.04) since is a 32-bit machine.

Installing Vagrant With VirtualBox On Windows
The problem with Windows is that it doesn't run Unix with X11! In order for you to ssh into, you have to use something like X-Win32. You can get X-Win32 from the ITS Software site. But the problem with X-Win32 is that it only works if you are on the USC networks (due to licensing). If your wireless connection is unstable, we are back to our original problem. So, our first step would be to install Cygwin. Please follow these steps to install Cygwin before proceeding.

Here are the quick and dirty steps to install Vagrant with VirtualBox:

  1. Follow these instructions to download and install VirtualBox and Vagrant. (Please note that there's a link to "Vagrant Cloud" there that's broken. Please use this link to the Vagrant Cloud instead.) If your machine is a 64-bit machine, download and install the 64-bit version of these software. But please make sure to install a 32-bit Ubuntu system even if you are using a 64-bit virtual machine container.

  2. Run a Cygwin Terminal and type the following into the Cygwin Terminal (lines that start with "#" are instructions and not commands):
        mkdir ~/Vagrant
        mkdir ~/Vagrant/sitepoint
        mkdir ~/Vagrant/shared-ubuntu-vagrant
        pushd ~/Vagrant/sitepoint
        vagrant init
        rm Vagrantfile
        vagrant init ubuntu/trusty32
        nano Vagrantfile
        # nano is a text editor (you can also use "vi" if you are familiar with it), do the following in nano:
        # Uncomment and change:
        #     config.vm.synced_folder "../data", "/vagrant_data"
        # to:
        #     config.vm.synced_folder "../shared-ubuntu-vagrant", "/outside"
        vagrant up

  3. Now you have a barebone Ubuntu 14.04 running inside VirtualBox. We will refer to this Ubuntu 14.04 running inside VirtualBox as "VagrantBox". To further setup your VagrantBox, you need to ssh into it by typing the following into the Cygwin Terminal:
        ssh -X -Y vagrant@ -p2222
    Use "vagrant" as your user name and "vagrant" as your password whenever you are prompted for a password when are you dealing with the VagrantBox. The above command is the command you must use to ssh into your VagrantBox (from a Cygwin Terminal).

    When you are inside your VagrantBox, if you want to use tcsh instead of bash, you should install tcsh by typing:

            sudo apt-get install -y tcsh
    To change your default login shell to tcsh, do:
    Enter /bin/tcsh as your new shell.

  4. Run the following commands to install more software since this is a barebone system:
        sudo apt-get install -y gdb
        sudo apt-get install -y lynx
        sudo apt-get install -y libssl-dev
        sudo apt-get install -y wireshark
        sudo apt-get install -y Xorg
  5. Type "exit" to disconnect from your VagrantBox.

  6. You are all setup now! Here is the summary of 3 important commands to use your VagrantBox:
    To turn off the VagrantBox, type the following into a Cygwin Terminal:
            pushd ~/Vagrant/sitepoint; vagrant halt; popd
    The above command is the command you must use to shutdown your VagrantBox (from a Cygwin Terminal).

    To turn on your VagrantBox (from a Cygwin Terminal), do:

            pushd ~/Vagrant/sitepoint; vagrant up; popd
    To ssh to your VagrantBox (from a Cygwin Terminal), do:
            ssh -X -Y vagrant@ -p2222
To exchange files between your VagrantBox and your Cygwin system, a shared folder is used. Based on the above setup, inside your VagrantBox, "/outside" is the shared folder; inside your Cygwin system, "mkdir ~/Vagrant/shared-ubuntu-vagrant" is the same shared folder. This way, if you want to backup some code you wrote for your programming assignments into your cloud drive, you can just copy your data into the VagrantBox shared folder and add the Cygwin shared folder to your favorite cloud drive.
Installing Vagrant With VirtualBox On Mac OS X
Mac Os X is running Unix, but it's not running X11. Therefore, you need to first install X11. Download and install XQuartz, which includes X11 server and client software. After it's installed, run from the Utilities folder in Applications. You should get a window with "xterm" in the titlebar. This is your "terminal" window running a Unix "shell".

The rest of the procedure is the same as for Windows! The only difference is that instead of using a Cygwin Terminal, you will be using a "terminal/xterm".


   [Please see copyright regarding copying.]