How to Install VirtualBox 7 Ubuntu 24.04, 22.04, or 20.04

VirtualBox 7 is a powerful open-source virtualization software that allows you to run multiple operating systems simultaneously on a single machine. With VirtualBox, you can create and manage virtual machines (VMs) that support a wide range of guest operating systems, including Linux, Windows, macOS, and more. Version 7 of VirtualBox introduces several enhancements, such as improved 3D support, better integration with cloud services, and an updated user interface, making it even more user-friendly and versatile.

On Ubuntu 24.04, 22.04, or 20.04, installing VirtualBox 7 is straightforward and can be done using Oracle’s official repository. This ensures that you get the latest version of VirtualBox, along with all necessary updates and security patches. This guide will walk you through the steps to install VirtualBox 7 on your Ubuntu system, allowing you to easily create and manage virtual environments.

Import VirtualBox 7 APT Repository

Update Ubuntu Before VirtualBox 7 Installation

Before installing VirtualBox 7, it’s paramount that your Ubuntu system is up-to-date. Having the most recent version of all packages ensures a seamless installation process, eliminating potential conflicts arising from outdated software components.

Updating the package list on your Ubuntu system is the first step. This ensures that your system is aware of the latest available versions of each package. You can do this by running the following command in your terminal:

sudo apt update

Upon updating the package list, the next step involves upgrading the packages. The upgrade process will replace any outdated packages with their latest versions. Achieve this by executing the following command:

sudo apt upgrade

Install Initial Packages Required For VirtualBox 7

To successfully install VirtualBox, your system must have specific prerequisite packages. Although most of these packages would typically already exist on your Ubuntu system, verifying their installation is prudent.

Execute the following command to ensure that all the required dependencies are in place:

sudo apt install dirmngr ca-certificates software-properties-common apt-transport-https curl -y

If installation issues arise in subsequent steps, consider revisiting this step and re-executing the command.

Import VirtualBox 7 GPG Key

To ensure the authenticity and integrity of the packages you install, you need a GPG (GNU Privacy Guard) key. This GPG key, part of a public key cryptography system, verifies that the packages come directly from the official VirtualBox repository.

To import the GPG key, run the following command:

curl -fSsL https://www.virtualbox.org/download/oracle_vbox_2016.asc | gpg --dearmor | sudo tee /usr/share/keyrings/virtualbox.gpg > /dev/null

Inclusion of the VirtualBox Repository

After incorporating the GPG key, add the official VirtualBox repository to your system. The following command will work for Ubuntu distributions.

echo "deb [arch=$( dpkg --print-architecture ) signed-by=/usr/share/keyrings/virtualbox.gpg] http://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox-7.list

Having added the VirtualBox repository, the final step is to update your system’s repository list. This ensures that your system recognizes the newly incorporated VirtualBox repository. Achieve this by executing the following command:

sudo apt update

Finalize VirtualBox 7 Installation via APT Command

After completing the VirtualBox repository import, we’ll establish VirtualBox 7 on your Ubuntu system.

Install VirtualBox 7 and Ubuntu Headers

Our initial task is to install VirtualBox 7. This operation will simultaneously install the pertinent Ubuntu headers corresponding to your kernel version. This is a prerequisite for VirtualBox to operate correctly. Execute the command below:

sudo apt install virtualbox-7.0 linux-headers-$(uname -r) -y

This command prompts Ubuntu to fetch and install VirtualBox 7 and the appropriate Linux headers from the repository for your specific kernel version.

Confirming the Installation

Use the apt-cache policy command to ensure the VirtualBox installation came directly from the repository we added earlier. This command details the package’s priority, version number, and originating repository.

apt-cache policy virtualbox-7.0

Upon executing the command, you’ll receive an output similar to the following:

Evaluate the output carefully. Ensure the version number matches VirtualBox 7 and confirm that the repository is the official VirtualBox repository we imported earlier.

Confirm VirtualBox 7 Service Status

With the installation confirmed, we need to assess the present status of the “vboxdrv” service. This service governs the management of VirtualBox kernel modules. We do this by executing the following command:

systemctl status vboxdrv

This command presents you with the service’s status, detailing whether it’s active and running. Here’s an example of what you might see:

You should observe an output reflecting the active service, indicating a successful installation.

Step 4: Enable VirtualBox 7 Service (If Required)

In some instances, the vboxdrv service may not be activated by default after installation. To launch the service and facilitate it to run automatically at system boot, utilize the following command:

sudo systemctl enable vboxdrv --now

When you execute this command, ensure the VirtualBox service operates correctly and prep your system for VirtualBox 7 usage. This ends the installation phase, and you have now equipped your Ubuntu system with VirtualBox 7, making it ready for use.

Initiating VirtualBox 7 via CLI or GUI Application Icon

CLI Method to Launch VirtualBox 7

You can launch VirtualBox using a simple command if you like working directly from the terminal. Enter the following command in your terminal:

virtualbox

GUI Method to Launch VirtualBox 7

Launching VirtualBox from the desktop environment offers a more intuitive experience for users who prefer a graphical interface. To do this, follow these steps:

  • Locate the Activities option at the top of your screen and click on it.
  • Choose Show Applications from the dropdown menu.
  • Find and select Oracle VM Virtualbox from the list of applications.

Install VirtualBox Extension Pack (Optional)

While not necessary, the VirtualBox Extension Pack is a highly beneficial add-on that can significantly enhance your VirtualBox experience by providing several advantageous features.

Download VirtualBox 7 Extension Pack

Ensure you download the Extension Pack version that matches the VirtualBox version on your Ubuntu system. To find out your VirtualBox version, run this command:

vboxmanage -v | cut -dr -f1

This command will return the version number in a format similar to ‘7.0.x’. With this information, you can proceed to download the appropriate Extension Pack using the wget command:

wget https://download.virtualbox.org/virtualbox/7.0.x/Oracle_VM_VirtualBox_Extension_Pack-7.0.x.vbox-extpack

Note: Replace each instance of ‘7.0.x’ in the URL with your specific VirtualBox version.

Install VirtualBox 7 Extension Pack

To install the Extension Pack that you just downloaded, employ the vboxmanage command:

sudo vboxmanage extpack install Oracle_VM_VirtualBox_Extension_Pack-7.0.x.vbox-extpack

Oracle will ask you to agree to its license terms and conditions during installation. Type “y” and press Enter to confirm your agreement.

Confirm the Version of the Installed Extension Pack

To validate the version of the Extension Pack that you installed, use the following command:

vboxmanage list extpacks

This command will display vital information about the installed Extension Packs, including their version numbers.

Add User into the vboxusers Group

To use VirtualBox, add your user account to the vboxusers group. Achieve this by running:

sudo usermod -a -G vboxusers $USER

You’ll need to reboot your system for these changes to take effect. After logging back in, verify that your user account has been successfully added to the vboxusers group by using:

groups $USER

This command lists the groups with which your user account associates. Ensure that “vboxusers” appears on this list. After following these steps, you can fully utilize the advanced features of the VirtualBox Extension Pack.

Additional VirtualBox 7 Commands

Update VirtualBox 7

Use the terminal to check and apply updates to ensure your VirtualBox 7.0 installation stays updated. Enter the following command to do this:

sudo apt update && sudo apt upgrade

Remove VirtualBox 7

If at any point you decide to remove VirtualBox from your system entirely, the following command allows you to do so:

sudo apt remove virtualbox-7.0

Remove VirtualBox 7 Repository

If you wish to remove the repository sources file, you can accomplish this by executing the following command:

sudo rm /etc/apt/sources.list.d/virtualbox.list

Remove VirtualBox 7

If you decide to delete the GPG key, use the command below:

sudo rm /usr/share/keyrings/virtualbox.gpg

Final Thoughts

Installing VirtualBox 7 on Ubuntu using Oracle’s official repository successfully equips your system with a robust and up-to-date virtualization platform. With this setup, you can now efficiently create and manage virtual machines tailored to your needs. To ensure continued stability and access to the latest features, it’s crucial to regularly check for updates from Oracle’s repository. Always ensure that your host system meets the necessary hardware requirements, particularly when running multiple VMs, to avoid performance issues. This installation not only enhances your ability to run diverse operating systems concurrently but also provides a secure environment for testing and development.

3 thoughts on “How to Install VirtualBox 7 Ubuntu 24.04, 22.04, or 20.04”

  1. amazing guide – the best I’ve seen
    I would love you to add a section on how to install the guest additions in the guest os
    I run into problems with installing guestadditions on the Arch VM

    Reply
  2. Thank you for the accurate and easy-to-follow instructions.
    I installed the stable version, not the nightly, but everything seems to work fine.

    Reply

Leave a Comment