How to install VirtualBox on Ubuntu (2023)

You can install VirtualBox on Ubuntu in at least two ways, and in this guide, you will learn how.

Ubuntu install VirtualBox

On Ubuntu, you can download and install VirtualBox, and in this guide, you will learn how. VirtualBox is a free and open-source hypervisor that runs on Linux, Windows, macOS, and even Solaris. It allows you to create virtual machines (VMs) on your computer to run different operating systems. This means you can run Ubuntu on your computer alongside Windows 11 or another flavor of Linux, or you can use it to test new operating systems without installing them on your physical hardware.

You can install VirtualBox on devices with Intel or AMD hardware, and even though it is a product meant for developers, testers, and system administrators, anyone can use it for free.

This guide will teach you the steps to download and install VirtualBox on an Ubuntu server.

Install VirtualBox on Ubuntu (Local repository)

To download and install VirtualBox on Ubuntu, use these steps:

  1. Open Terminal on Ubuntu.

  2. Type the following command to check that the local package index is up to date and press Enter:

    sudo apt update
  3. Type the following command to download and install VirtualBox and press Enter:

    sudo apt-get install virtualbox

    Ubuntu install VirtualBox

  4. Type “Y” and press Enter.

  5. Type the following command to install the VirtualBox Extension Pack and press Enter:

    sudo apt-get install virtualbox-ext-pack
  6. Type “Y” and press Enter.

  7. Click the OK button.

    Ubuntu install VirtualBox ext pack

  8. Click the Yes button.

Once you complete the steps, you can launch the virtualization application by running the “virtualbox” command or selecting the app from the app launcher.

It’s important to note that these instructions will install the latest version of VirtualBox available in the repository. If you want to install the most up-to-date version, you may need to use the Oracle repository (see steps below).

Install VirtualBox on Ubuntu (Oracle repository)

Alternatively, you can download and install the virtualization software from the Oracle repositories.

To install VirtualBox from Oracle repositories, use these steps:

  1. Open Terminal on Ubuntu.

  2. Type the following command to check that the local package index is up to date and press Enter:

    sudo apt-get install -y software-properties-common

    Ubuntu install VirtualBox from Oracle

  3. Type the following command to download and install GPG keys and press Enter:

    curl https://www.virtualbox.org/download/oracle_vbox_2016.asc | gpg --dearmor > oracle_vbox_2016.gpg
  4. Type the following command as well and press Enter:

    curl https://www.virtualbox.org/download/oracle_vbox.asc | gpg --dearmor > oracle_vbox.gpg
  5. Type the following command and press Enter:

    sudo install -o root -g root -m 644 oracle_vbox_2016.gpg /etc/apt/trusted.gpg.d/
  6. Type the following command and press Enter:

    sudo install -o root -g root -m 644 oracle_vbox.gpg /etc/apt/trusted.gpg.d/

    VirtualBox repository keys

  7. Type the following command to add the VirtualBox repository to Ubuntu and press Enter:

    echo "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list
  8. Type the following command to check that the local package index is up to date and press Enter:

    sudo apt update
  9. Type this command as well and press Enter:

    sudo apt install -y linux-headers-$(uname -r) dkms
  10. Type the following command to install VirtualBox and press Enter:

    sudo apt install virtualbox-7.0 -y

    Ubuntu install VirtualBox from Oracle

  11. Type the following command to download the VirtualBox Extension Pack and press Enter:

    wget https://download.virtualbox.org/virtualbox/7.0.0/Oracle_VM_VirtualBox_Extension_Pack-7.0.0.vbox-extpack
  12. Type the following command to import the VirtualBox Extension Pack into Ubuntu and press Enter:

    sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-7.0.0.vbox-extpack

    Ubuntu install VirtualBox latest extensions

After you complete the steps, VirtualBox will install on the device. You can start creating virtual machines.

In the above commands, you may have to update the version number, depending on when you’re reading these instructions. These instructions will install VirtualBox version 7.0.