VirtualBox is an open source cross-platform virtualization software that allows you to run multiple operating systems (virtual machines) simultaneously.
In the guides in this tutorial, I will show you two different methods on how to install VirtualBox on your Ubuntu 18.04 OS. The first method describes the steps required to install VirtualBox 6.0 from the Oracle repositories while the second will show you how to install the latest version of VirtualBox from the official Ubuntu repositories.
The VirtualBox packages available in Ubuntu’s multiverse repositories may not always be the latest versions. If you want to have the latest version of VirtualBox then the recommended way is to install VirtualBox from the Oracle repositories.
This guide is the same for Ubuntu 16.04 and linux distribution other Ubuntu-based, including Linux Mint and Elementary OS.
Before continuing with this tutorial on how to install VirtualBox on Ubuntu, make sure you are logged in as a user with sudo privileges. Read → How to Create a Sudo User and a Sudo Group on Ubuntu.
Install VirtualBox from the Oracle Repositories
At the time of writing this article, the latest version of VirtualBox is version 6.0. Before proceeding with the next steps you should check VirtualBox download page to see if a newer version is available.
To install VirtualBox from the Oracle repositories on your Ubuntu operating system, follow these steps:
Start by importing the GPG key from the Oracle VirtualBox repository to your system using the command
$ wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
$ wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
Both commands should display
OK which means that the GPG Key has been successfully imported and packages from this repository will be considered trusted.
Next, add APT Repository VirtualBox with commands
add-apt-repository as shown below:
$ sudo add-apt-repository "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib"
$ (lsb_release -cs) will print the Ubuntu codename. For example, if you have Ubuntu version 18.04 command will print the name
If you get an error message saying command
add-apt-repository not found then you need to install the package
Once the VirtualBox repository is enabled, update the list
apt package and install the latest version of VirtualBox 6.0 by typing the following command:
$ sudo apt update
$ sudo apt install virtualbox-6.0
Install the VirtualBox Extension Pack
The VirtualBox Extension Pack provides several useful functions for guest machines such as virtual USB 2.0 and 3.0 devices, support for RDP, image encryption and more.
Download the extension pack file by typing:
$ wget https://download.virtualbox.org/virtualbox/6.0.0/Oracle_VM_VirtualBox_Extension_Pack-6.0.0.vbox-extpack
Make sure the Extension Pack version matches the VirtualBox version.
When the download is complete, import the extension pack using the following command:
$ sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-6.0.0.vbox-extpack
You will be granted an Oracle license and asked to accept their terms and conditions.
Do you agree to these license terms and conditions (y/n)?
y and press
Enter. After the installation is complete, you will see the following output:
Output 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% Successfully installed "Oracle VM VirtualBox Extension Pack".
Install VirtualBox from the Ubuntu Repositories
Installing VirtualBox from the Ubuntu repositories is a really easy process, just run the following command:
$ sudo apt update
$ sudo apt install virtualbox virtualbox-ext-pack
Start Using VirtualBox
Now that VirtualBox is installed on your Ubuntu system, you can open VirtualBox from the command line by typing
virtualbox or by clicking the VirtualBox icon (Activities -> Oracle VM VirtualBox).
When you start VirtualBox for the first time, a window like the following will appear:
You have learned how to install VirtualBox on your Ubuntu 18.04 OS. You can now install Guest Machines like Windows OS or any other Linux Distro. To find more information about VirtualBox, visit the official VirtualBox documentation page.