How to Install VirtualBox on Ubuntu

By 

Updated on

3 min read

Install VirtualBox on Ubuntu 24.04

VirtualBox is a powerful open-source virtualization tool that lets you create and run multiple virtual machines on your computer, regardless of the host operating system. It provides a safe environment where you can experiment with different operating systems, applications, and configurations without affecting your primary system. VirtualBox is an excellent choice for testing and development work.

In this guide, we will walk you through the installation of VirtualBox on Ubuntu 24.04 using the Oracle repositories.

It is recommended to install VirtualBox using the Oracle repository rather than the default Ubuntu repository.

The Oracle repositories always have the most up-to-date release available for installation. The VirtualBox package available in the Ubuntu multiverse repository may not be the most recent version.

Installing VirtualBox from the Oracle Repositories

Installing VirtualBox is a straightforward process and can be completed within a matter of minutes. At the time of writing, the latest version of VirtualBox is 7.2.4.

To install VirtualBox from the Oracle repositories, follow these steps:

  1. Start by updating the package index by issuing the following command:

    Terminal
    sudo apt update
  2. Import the Oracle public key using the following command:

    Terminal
    wget -O- https://www.virtualbox.org/download/oracle_vbox_2016.asc | \
      sudo gpg --yes --output /usr/share/keyrings/oracle-virtualbox-2016.gpg --dearmor
  3. Add the VirtualBox APT repository to your system:

    Terminal
    echo "deb [arch=amd64 signed-by=/usr/share/keyrings/oracle-virtualbox-2016.gpg] https://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" | \
      sudo tee -a /etc/apt/sources.list.d/virtualbox.list

    $(lsb_release -cs) prints the Ubuntu codename. For example, if you have Ubuntu version 24.04, the command will print noble.

  4. Update the package list so your system knows that you added a new repository:

    Terminal
    sudo apt update
  5. You can now install the latest version of VirtualBox by running:

    Terminal
    sudo apt install virtualbox-7.2

    If you want to install another version, for example 6.1, replace virtualbox-7.2 with virtualbox-6.1 in the command above.

That’s it. You have successfully installed VirtualBox on your Ubuntu machine.

Installing VirtualBox Extension Pack

The VirtualBox Extension Pack provides several useful features for guest machines, including virtual USB 2.0 and 3.0 devices, support for RDP, image encryption, and more.

It is important to note that the version of the Extension Pack should match the version of the VirtualBox package already installed on your system. You can check the version of VirtualBox by typing:

Terminal
VBoxManage -version
output
7.2.4r<revision>

Save the version number without the r suffix to a variable:

Terminal
VBOX_VERSION=$(VBoxManage -version | cut -d'r' -f1)

Download the extension pack file by typing:

Terminal
wget https://download.virtualbox.org/virtualbox/${VBOX_VERSION}/Oracle_VM_VirtualBox_Extension_Pack-${VBOX_VERSION}.vbox-extpack
Info
Make sure you download the correct version.

When the download is completed, import the extension pack using the following command:

Terminal
sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-${VBOX_VERSION}.vbox-extpack

You will be presented with the Oracle license and prompted to accept their terms and conditions.

output
...

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

Type y and hit Enter. Once the installation is completed, 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".

Using VirtualBox

VirtualBox can be launched from the command line by typing virtualbox or by clicking on the VirtualBox icon.

When you start the application for the first time, a window like the following will appear:

Ubuntu Install Virtualbox

From here, you can create your first Windows or Linux guest machine by clicking the “New” button.

Conclusion

We’ve shown you how to install VirtualBox on Ubuntu 24.04.

For more information about VirtualBox, visit the official VirtualBox documentation page.

If you want to manage your virtual machines through the command line, read our guide on how to install Vagrant on Ubuntu 20.04 .

Feel free to leave a comment if you have any questions.

Linuxize Weekly Newsletter

A quick weekly roundup of new tutorials, news, and tips.

About the authors

Dejan Panovski

Dejan Panovski

Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.

View author page