Effortlessly Install VirtualBox on Ubuntu 24.04: A Comprehensive Guide

VirtualBox allows you to run multiple operating systems on a single host. This post provides two methods for installing VirtualBox on Ubuntu 24.04, enabling you to explore different operating systems without needing separate hardware. VirtualBox is an open-source virtualization solution that is free to use.

Method 1: Installing VirtualBox from Oracle’s Repository

If you want the latest version of VirtualBox, including the newest features and security patches, installing from Oracle’s repository is the recommended approach. This method ensures you have access to the most up-to-date software.

Step 1: Install Prerequisites

Before adding the Oracle VirtualBox repository, install the software-properties-common package. This package provides the necessary tools to manage software repositories.

$ sudo apt install software-properties-common

Step 2: Add GPG Keys

GPG keys verify the authenticity of the repository. Since the Oracle repository is a third-party source, installing the GPG keys ensures integrity and authenticity.

$ wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -

You should see output in your terminal confirming the key has been downloaded and installed.

Step 3: Add Oracle’s VirtualBox Repository

Add the VirtualBox repository to your /etc/apt/sources.list.d/ directory. This allows your system to find and install the VirtualBox packages.

$ echo "deb [arch=amd64] https://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list

This command creates a new repository entry, which will be used when installing VirtualBox.

Step 4: Install VirtualBox

Update the package index to include the newly added repository.

$ sudo apt update

Next, install VirtualBox specifying the desired version.

$ sudo apt install virtualbox-[version]

Replace [version] with the specific version number you wish to install (e.g., 7.1). Make sure the version is available on the VirtualBox website. Otherwise, the installation will fail.

Method 2: Installing VirtualBox via APT

Installing VirtualBox from the official Ubuntu repository using apt is a straightforward way to get a stable version.

Step 1: Update the Repository

Update the package index to ensure you have the latest information about available packages.

$ sudo apt update

Step 2: Install VirtualBox

Install the VirtualBox package.

$ sudo apt install virtualbox

Step 3: Verify the Installation

Check the installed version to confirm the successful installation.

$ VboxManage --version

VirtualBox offers a way to operate different OS environments on one machine. This guide outlined two methods to install VirtualBox on Ubuntu 24.04: directly from Ubuntu’s repository or by adding the Oracle repository for a specific version.