Read in 3 minutes
How To Install VirtualBox on Ubuntu 18.04
VirtualBox is an open source cross-platform virtualization software which allows you to run multiple guest operating systems (virtual machines) simultaneously.
In this tutorial we will show you two different methods on how to install VirtualBox on your Ubuntu 18.04 machine. The first method describe the steps necessary to install VirtualBox from the Oracle repositories while the second one will show you how to install the latest version of VirtualBox from the official Ubuntu repositories.
The VirtualBox package which is available in the Ubuntu multiverse repository may not always be the latest version. If you want to always have the latest version of VirtualBox then recommended approach is to install the VirtualBox from the Oracle repositories.
Although this tutorial is written for Ubuntu 18.04 Bionic Beaver the same steps can be used for Ubuntu 16.04 Xenial Xerus.
Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges.
Installing VirtualBox from Oracle repositories
To install VirtualBox from the Oracle repositories on your Ubuntu system, follow these steps:
Import VirtualBox GPG keys
First, we need to import the GPG keys of the Oracle VirtualBox repository to our system using the following commands:
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 output
OKwhich means that the keys are successfully imported and packages from this repository will be considered trusted.
Add the VirtualBox repository
Next, add the VirtualBox repository with the
add-apt-repositorycommand as shown bellow:
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 the command will print
If you get an error message saying
add-apt-repository command not foundthen you need to install the
Once the VirtualBox repository is enabled, update the
aptpackage list and install the latest version of VirtualBox 5.2 with:
sudo apt update sudo apt install virtualbox-5.2
Installing VirtualBox from Ubuntu repositories
Installing VirtualBox from Ubuntu repositories is a pretty straightforward process, just run the following commands:
sudo apt update sudo apt virtualbox virtualbox-ext-pack
Now that VirtualBox is installed on your Ubuntu system you can start it either from the command line by typing
virtualbox or by clicking on the VirtualBox icon (
Activities -> Oracle VM VirtualBox).
When you start VirtualBox for the first time, a window like the following should appear:
You have learned how to install VirtualBox on your Ubuntu 18.04 machine. You can now install your first Windows or Linux guest machine. To find more information about VirtualBox visit the official VirtualBox documentation page.
If you’d like to manage your virtual machines from the command line, check out this article on how to How to install Vagrant on Ubuntu 18.04.
If you have any question, please leave a comment below.