How to Install VirtualBox on Ubuntu 24.04


While working on a Linux environment, specifically on Ubuntu 24.04, installing other operating systems just for testing purposes can be inconvenient. You can try any other OS by just getting its virtual machine using the Oracle VirtualBox application. With this, you need not worry about transferring your files or editing the bootable drive. This is like creating a machine inside a machine.

Let’s cover all the steps for installing VirtualBox on Ubuntu 24.04.

Table of Contents:

How to Install VirtualBox on Ubuntu 24.04

To install VirtualBox, you can use the default Ubuntu repository or download the deb file for Oracle VirtualBox directly from its website. Another way of installing VirtualBox is by using Oracle’s official repository. After adding the VirtualBox repository, download and install it on your Ubuntu 24.04 system.

Let’s discuss these three ways of installing VirtualBox in Ubuntu 24.04.

Method 1: Installing VirtualBox from the Ubuntu Default Repository

For the default Ubuntu repository, the first thing you are going to do is update your Ubuntu system packages:

sudo apt update

Now download and install the VirtualBox using this simple install command:

sudo apt install virtualbox

Note: If you want to install the specific version of VirtualBox, then enter the above command and press the tab key. After that, check the version you need.

Now install the VirtualBox extension pack:

sudo apt install virtualbox-ext-pack

VirtualBox extension pack is an add-on for VirtualBox that unlocks extra features. It is like a plugin that gives you USB device support, remote access, and disk encryption features.

Read all the terms and click OK.

Tip: For pressing OK, use the tab key.

Agree with the VirtualBox PUEL license terms.

After VirtualBox installation, run it using this command:

virtualbox

You can also confirm the version of VirtualBox installed using this command:

VBoxManage --version

Method 2: Installing VirtualBox via Deb File

The second method for downloading VirtualBox is using its official deb file. First, download the deb file for the latest VirtualBox.

Note: Currently the latest VirtualBox file for Ubuntu 24.04 is not released, but you can use the Ubuntu 22.02 file for it.

Now navigate to the directory where the deb file is downloaded:

cd ~/Downloads

Now install the VirtualBox software on your Ubuntu 24.04 using its deb file.

sudo dpkg -i virtualbox-7.0_7.0.14-161095~Ubuntu~jammy_amd64.deb

Remember to modify the deb file name in the above command. To check your deb file name, you can use the ls command and copy it from there.

Finally, after VirtualBox installation, run it using this command:

virtualbox

Method 3: Installing VirtualBox Using Oracle’s Official Repository

Often the VirtualBox available in the official repository is different from the latest one. To get updated VirtualBox, download it from VirtualBox’s official repository. For that, first, add the VirtualBox repository to Ubuntu 24.04 by adding the GPG key of VB.

Before starting VirtualBox installation in Ubuntu 24.04 you need some prerequisite installation. VirtualBox requires the software-properties-common package to add software sources on Ubuntu. Install it with:

sudo apt install software-properties-common

Note: You may need to run the sudo apt –fix-broken install to complete the above installation without any error.

VirtualBox comes from a separate source, so we must add a GPG key to verify package authenticity. This key ensures you download genuine VirtualBox software.

Run this command to download and add the key:

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

The next step is to add the VB repository, for this execute:

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

The above command adds a VirtualBox reference to Ubuntu’s package manager settings. This includes the VirtualBox repository URL and your Ubuntu version’s number. The entry is stored in a file named virtualbox.list with the /etc/apt/sources.list.d/ directory. This allows the system to locate and download the VirtualBox package from the specific repository.

Update your system packages so the newly added key gets updated in your system configuration file:

sudo apt update

Finally, you can install VirtualBox from its official repository using this command:

sudo apt install virtualbox-7.0

Note: If you require any other version of VirtualBox, replace it in the above command. Currently, the latest version available is 7.

After installing, now get the VirtualBox extension pack:

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

The current latest version of the VirtualBox extension pack is 7.0.14, if you have installed any other version simply replace it in the above command.

Now import and install the VirtualBox extension pack using this command:

sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-7.0.14.vbox-extpack

Similarly, if you have any other version of VirtualBox, modify the above command accordingly. Confirm the installation upon asking and your VirtualBox is ready for working.

How to Create a Virtual Machine Using VirtualBox

To create a virtual machine inside Ubuntu 24.04 using the Oracle VirtualBox, first launch VirtualBox using this command:

virtualbox

A new window will start with the VirtualBox main page.

Click the New option for creating a new virtual machine. A setup window will pop up.

Now write the virtual machine name. VirtualBox will try to guess the operating system type and version based on your given name.

In the same window, select the ISO file for the system you want to create inside the VirtualBox and select Next.

Now create a Username, Password, and Hostname for the system. After that, click Next.

Going quickly forward, you have to allocate some system space and RAM for the Virtual machine to work. Once these steps are done, you will be able to boot into a new OS inside the VirtualBox installed on Ubuntu 24.04.

Simply click Start to boot the virtual machine.

How to Remove VirtualBox from Ubuntu 24.04

To remove the VirtualBox from Ubuntu 24.04 use the apt remove:

sudo apt remove virtualbox

If you have any important virtual machines (VMs) created with VirtualBox, make sure to back them up before proceeding. These are typically stored as .vdi files.

To remove the configuration files and settings specific to VirtualBox in your user directory, run:

rm -r ~/.config/VirtualBox/

Similarly, you can also run this command to remove VirtualBox and its configuration files:

sudo apt remove --purge virtualbox*

Conclusion

To install VirtualBox on Ubuntu 24.04 you can use three different ways. The simplest way is using the Ubuntu default package repository. But this may not give you the latest version of VirtualBox. To get the latest version, you have to either add the Oracle VirtualBox official repository to your system by using the GPG key or directly download the deb file from their official website. Either of the two methods will give you the latest version of VirtualBox. Once installed, simply launch and create a new virtual machine inside the Ubuntu 24.04 system.

Print Friendly, PDF & Email
Categories