This guide will walk you through the setup and configuration of virtual machines using VirtualBox.
First you will need to download VirtualBox, which you can find here: https://www.virtualbox.org/wiki/Downloads
Then, for this tutorial you will also need to download Lubuntu. We will be using a spcific version, 18.04.5 LTS Alternate 64-bit, which you can find on this page in the Alternate install image section: https://cdimages.ubuntu.com/lubuntu/releases/bionic/release/
Run the VirtualBox installer. You may be asked to confirm that installation will reset your network connections and download additional dependencies for your host operating system. Please refer to the user manual if you need additional help: https://www.virtualbox.org/manual/UserManual.html#installation
Once VirtualBox finishes installing, launch the program.
When you first run VirtualBox, you should see a screen similar to this:
Clicking the blue "New" button will open a dialog pictured below:
Fill out the Name field with whatever you would like the name this new VM. "Lubuntu" is fine for now but you may want to be more descriptive if you plan to have multiple VMs running the same OS in the future.
Using the ISO Image dropdown, select "Other..." from the list, which will open another dialog to search for a file on your PC. Navigate to and select the Lubuntu ISO file you downloaded previously.
With both of these fields configured you can proceed to the next step.
Here you will be able to customize the admin account details and the VM's network options. You can leave these at their default values as shown above and proceed to the next screen.
Here you can customize the CPU and memory resources available to the VM. The default values may vary depending on your host PC's capabilities. You can leave these at their default values as well and proceed to the next step.
On this screen you can configure the vitual hard drive that will be used by this VM, or choose an existing one. You can lower the default value to something smaller, such as 3 GB. A special property of virtual hard disks in a program such as Virtualbox is that they can be resized as needed, so setting this to a smaller value at first is fine. Setting it too low may prevent the VM from being able to install however, so a few GB is generally a good number. If you select "Pre-allocate Full Size", the newly created disk file will take up the entire size you configure here. You can leave this unchecked and proceed to the next step.
Finally you will be shown a summary of the settings you configured. Click "Finish", after which VirtualBox will automatically start the new VM and proceed with the initial OS installation process for you.
VirtualBox will automatically install the OS when following the steps outlined above. However, you may run into an error screen during installation.
This error can be safely ignored. With the VM window focused, you can press Enter
on your keyboard to continue with installation, and soon afterward the VM will automatically restart once OS installation finishes.
You'll then get a prompt asking you to login with the root user details we specified previously. If you've reached this screen, you're done!
Q: How do I shut down the VM from the command line?
A: You can use either the command sudo poweroff
or sudo shutdown -h now
to immediately perform a graceful power off of the machine.
Q: I'm running into an error: "user is not in the sudoers file"
, how can I fix this?
A: VirtualBox by default doesn't add your user specified in the VM configuration screens to the sudoers file, and so you need to do this manually. Here's the steps to accomplish this assuming vboxuser
and changeme
are the username and password you used when configuring your new VM:
First, change to the root user with:
su -
You will be prompted to enter a password. It will be the same as the password yo set for vboxuser
during VM configuration.
Next, add the user you'd like give sudo permissions to with the following command:
sudo adduser vboxuser sudo
Finally, to switch back to this user (instead of continuing as the root
user), enter the following:
su vboxuser