How to install VirtualBox on Ubuntu 18.04

s2 0

VirtualBox
is a cross-platform open source virtualization software that allows you to run multiple guest operating systems (virtual machines) at the same time.

In this tutorial, we are going to show you two different methods of installing VirtualBox on your Ubuntu 18.04 computer. The first method describes the steps required to install VirtualBox 6.0 from the Oracle repositories, while the second shows you how to install the latest version of VirtualBox from the official Ubuntu repositories.

The VirtualBox package available in the Ubuntu Multiverse Repository may not always be the latest version. If you always want to have the latest version of VirtualBox, it is advisable to install the VirtualBox from the Oracle repositories.

The same instructions apply to Ubuntu 16.04 and all Ubuntu-based distributions, including Linux Mint and Elementary OS.

requirements

Before proceeding with this tutorial, make sure that you are logged in as a user with sudo permissions.

Install VirtualBox from Oracle Repositories

At the time of this writing, the latest version of VirtualBox is version 6.0. Before proceeding with the next steps, you should have the VirtualBox download page
to see if a newer version is available.

To install VirtualBox from the Oracle repositories on your Ubuntu system, do the following:

  1. Start by importing the Oracle VirtualBox repository’s GPG keys into your system using the following wget 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 be issued OK This means that the keys have been imported successfully and packages from this repository are trusted.

  2. Next add the VirtualBox APT repository with the. added add-apt-repository Command as shown below:

    sudo add-apt-repository "deb [arch=amd64] https://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib"

    $(lsb_release -cs) prints the Ubuntu code name. For example, if you have Ubuntu version 18.04, the command will be printed bionic.

    If you get an error message that says add-apt-repository command not found then you have to install that software-properties-common Package.

  3. Once the VirtualBox repository is enabled, update the apt package list and install the latest version of VirtualBox 6.0 using:

    sudo apt updatesudo apt install virtualbox-6.0

Install the VirtualBox expansion pack

The VirtualBox Extension Pack provides several useful features for guest machines such as USB 2.0 and 3.0 virtual 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 expansion pack using the following command:

sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-6.0.0.vbox-extpack

You will be presented with the Oracle license and asked to accept its terms.

Do you agree to these license terms and conditions (y/n)?

Type y and hit Enter. Once the installation is complete, you will see the following output:

0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Successfully installed "Oracle VM VirtualBox Extension Pack".

Install VirtualBox from Ubuntu repositories

Installing VirtualBox from Ubuntu repositories is a pretty straightforward process. Just run the following commands:

sudo apt updatesudo apt install virtualbox virtualbox-ext-pack

Start VirtualBox

Now that VirtualBox is installed on your Ubuntu system, you can either start it from the command line by typing virtualbox or by clicking the VirtualBox icon (Activities -> Oracle VM VirtualBox).

The first time you start VirtualBox you should see a window like the following:

Conclusion

You learned how to install VirtualBox on your Ubuntu 18.04 computer. You are now ready to install your first Windows or Linux guest computer. For more information on VirtualBox, see the official VirtualBox documentation
Page.

If you want to manage your virtual machines from the command line, check out this article on how to install Vagrant on Ubuntu 18.04.

If you have any questions please leave a comment below.