We are providing a virtual machine for you to use to write your scripts and programs. It is essentially a sandbox for you to test your code without the risk of ruining your system or deleting your Openlab files. Once you have tested your code, you can send it directly to your Openlab network drive for submission.
We will be grading your assignments using the same virtual machine. There is an advantage of doing this, in that if it works on the virtual machine for you it will likely work the same on our virtual machine.
The virtual machine has Ubuntu Server 18.04.2 installed. The settings are such that you should be able to run it on your computers without taking too much resources (assuming that virtualization is enabled in the BIOS). It will also be more than sufficient for the assignments you will be working on.
This guide will hopefully explain everything that you will need to know to use it.
For this virtual machine, I recommend using Oracle's VirtualBox version 6+. It is available for all operating systems and can be downloaded from https://www.virtualbox.org/wiki/Downloads.
Note for Hyper-V users: If you happen to have Hyper-V enabled in Windows, then VirtualBox will be unable to utilize your CPU's virtualization feature (if you are unsure whether its enabled, it probably isn't). The virtual machine will still work, but will be considerably slower. You can always try to convert it for use with Hyper-V, but this is not straight forward and will not be covered here.
Once you've downloaded VirtualBox, you can install it. I recommend keeping the default settings during installation.
You will be provided an Open Virtualization Appliance cs146-2019spring.ova
either via the website or by email. To install, open VirtualBox and go to "File->Import Appliance...". The first window will ask you to specify the location of the appliance file. Then press next. You will now be shown a list of virtual machine settings; do not change any of those settings. Below, find "MAC Address Policy"; here, you will choose "Generate new MAC addresses for all network adapters". Now you can press "Import".
Once installed, you should be able to select the virtual machine in the list and start it using the "Start" button. If successful, you should eventually see a terminal login prompt. If you encounter any issues, please email me at sstahlhe@uci.edu.
For computers with HiDPI: You can go into settings, and under "Display", change the "Scale Factor" to your liking.
You may find it convenient to connect to the server via SSH. The built-in terminal emulator lacks many features that other terminal emulators have, such as the ability to scroll back through the buffer. You can also use scp
and sftp
(pscp
and psftp
using PuTTY) to copy files to the virtual machine or from the virtual machine. The following shows how to connect to the virtual machine from your local computer.
When logging in directly, a message will be shown welcoming you to Ubuntu. Below, where it shows the system information, there is an entry "IP address for enp0s3", where you can find the IP address. It should be something like 192.168.56.*
. Whatever it is, that is the IP address that you will be connecting to with OpenSSH or PuTTY.
You can also find its IP address by using the ifconfig
command. It will show the IP address under "enp0s3" to the right of "inet".
Note, however, that this IP address is only accessible from the computer hosting the virtual machine.
To connect to the virtual machine with OpenSSH, you can simply type the command ssh cs146@<IP ADDRESS>
where <IP ADDRESS>
is the IP address that you previously found. For example:
ssh cs146@192.168.56.101
If successful, it will ask you if you want to connect to the host. Type "yes" and enter the password.
In PuTTY, enter the IP address you found in the "Host Name (or IP address)" field. Make sure that you are connecting with SSH on port 22. You can adjust the settings according to your preference and save them for easy loading. Once you are ready, just press "Open" at the bottom of the window.
If successful, it will ask you if you want to connect to the host. Accept and enter the password.
Whether using the built-in terminal or having SSH'd into the virtual machine, you can use scp
or sftp
from the virtual machine to send your files directly to your Openlab network drive. For example, from the virtual machine you can use the command:
scp hw.sh anteater@openlab.ics.uci.edu:~/assignments/hw/
to copy hw.sh
to assignments/hw/
in your home directory.
Make sure to backup your files often so that you do not lose them accidentally. If you want a challenge, you can always write a script that will automatically backup your assignments on Openlab. For example, use tar
to package up your assignment directory and use scp
to send it to your Openlab network drive. You can also copy with a timestamp. For example:
scp "backup.tar" "anteater@openlab.ics.uci.edu:~/backups/assignments-$(date +%Y%M%dT%H%M%S).tar"
Also, you are allowed to use the "Shared Folders" feature to access files from your computer. You will have to install the VirtualBox "Guest Additions". You can do this by running sudo apt install virtualbox-guest-utils
. There are plenty of guides online on how to setup the shared folder, and how to mount it in the virtual machine.