Read in 2 minutes

last updated 

How To Install VirtualBox on Ubuntu 18.04

In this tutorial we’ll show you how to install VirtualBox on a Ubuntu 18.04 machine.

VirtualBox is an open source cross-platform virtualization software which allows you to run multiple guest operating systems (virtual machines) simultaneously.


Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges.

Installing VirtualBox

The VirtualBox installation package which is available in the Ubuntu multiverse repository may not always be the latest version. The recommended approach is to install the latest VirtualBox package from the official VirtualBox repositories.

Although this tutorial is written for Ubuntu 18.04 Bionic Beaver the same steps can be used for Ubuntu 16.04 Xenial Xerus.

To install VirtualBox on your Ubuntu system, follow these steps:

  1. 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 -O- | sudo apt-key add -
    wget -q -O- | sudo apt-key add -

    Both commands should output OK which means that the keys are successfully imported and packages from this repository will be considered trusted.

  2. Add the VirtualBox repository

    Next, add the VirtualBox repository with the add-apt-repository command as shown bellow:

    sudo add-apt-repository "deb $(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 bionic.

  3. Install VirtualBox

    Once the VirtualBox repository is enabled, update the apt package list and install the latest version of VirtualBox 5.2 with:

    sudo apt update
    sudo apt virtualbox-5.2

Starting VirtualBox

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 have any question, please leave a comment below.