How to Install VirtualBox on Ubuntu

March 13, 2024

Introduction

VirtualBox is a powerful open-source virtualization software developed by Oracle. It allows users to run multiple operating systems simultaneously on a single machine. Installing VirtualBox on Ubuntu enables users to experiment with different operating systems, test software, and develop applications in isolated virtual environments.

In this article, you will learn how to install VirtualBox on Ubuntu using three different methods.

How to Install VirtualBox on Ubuntu

Prerequisites

Option 1: Install VirtualBox from Ubuntu Repositories

One way to install VirtualBox is to use the official Ubuntu repositories. The process is straightforward and performed using the package manager (apt).

To install VirtualBox, follow the steps in the sections below.

Step 1: Install VirtualBox

Before installation, update the package repository with:

sudo apt update
sudo apt update terminal output

Next, download and install VirtualBox by running:

sudo apt install virtualbox
sudo apt install virtualbox terminal output

Note: To select a specific VirtualBox version, run sudo apt install virtualbox and hit Tab to see the various VirtualBox versions available for installation.

Step 2: Install the VirtualBox Extension Pack.

The Extension Pack provides additional features and support for USB 2.0 and USB 3.0 devices, VirtualBox Remote Desktop Protocol (VRDP) support, Disk encryption, Intel PXE boot ROM, etc.

To install the VirtualBox Extension Pack, take the following steps:

1. Run the command:

sudo apt install virtualbox-ext-pack

2. Read the VirtualBox Extension Pack Personal Use and Evaluation License (PUEL) and select <Ok> to confirm.

vbox extension pack license

3. Accept the VirtualBox PUEL license terms by selecting <Yes> and hitting Enter.

Agree to the vbox extension pack license terms

Once the installation is completed, VirtualBox is ready to run. Start it by executing:

virtualbox

The command has no output but starts VirtualBox.

Option 2: Installing VirtualBox from Oracle's Repositories

Often, the default repositories do not have the latest software versions. For example, run the following command to see the latest VirtualBox version installed via the Ubuntu repository:

VBoxManage --version
VBoxManage --version terminal output

The installed version is 6.1.50, while the latest version on the VirtualBox website is 7.0.14.

VirtualBox package download for the latest version on the official website.

The older version may work for test environments, but some users need the latest security or functionality patches. The solution is to install VirtualBox from Oracle Repositories. This process is more in-depth but installs the most recent VirtualBox version on Ubuntu.

Step 1: Install Supporting Software

The software-properties-common package is required to run Virtualbox on Ubuntu. It allows users to add new software repositories.

Enter the following command to install the package:

sudo apt install software-properties-common
sudo apt install software-properties-common terminal output

Step 2: Install GPG Key

Adding GPG keys to the system ensures the integrity and authenticity of the packages you install, especially from third-party repositories like the VirtualBox repository.

To download and install GPG keys, enter:

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

Note: Refer to our guide How to Delete GPG Keys to learn how to delete GPG keys using different methods.

Step 3: Add VirtualBox Repository to Ubuntu

To add the VirtualBox repository, enter the command :

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

The command creates a repository entry for VirtualBox in Ubuntu's package manager configuration file, specifying the appropriate URL and Ubuntu release codename. It then writes this entry to a file named virtualbox.list in the /etc/apt/sources.list.d/ directory. Then, the system can fetch and install VirtualBox packages from the added repository.

The output deb [arch=amd64] https://download.virtualbox.org/virtualbox/debian jammy contrib indicates the command successfully wrote the VirtualBox repository entry to the specified file.

Step 4: Install the Latest Version of VirtualBox

Before installation, update the package lists:

sudo apt update
terminal output for sudo apt update

2. Use the following syntax to install VirtualBox on Ubuntu:

sudo apt install virtualbox-[version-number]

At the time of writing this article, the latest VirtualBox version is 7.0.14. Therefore, to install it, run:

sudo apt install virtualbox-7.0
sudo apt install virtualbox-7.0 terminal output

The command installs the version of VirtualBox currently available in the added repository.

Step 5: Install VirtualBox Extension Pack

The VirtualBox Extension Pack enhances the virtual machines' functionality. Install it by taking the following steps:

1. Download the Extension Pack:

wget https://download.virtualbox.org/virtualbox/[version-number]/Oracle_VM_VirtualBox_Extension_Pack-[version-number].vbox-extpack

The current extension pack version on the VirtualBox website is 7.0.14. Therefore, the command is:

wget https://download.virtualbox.org/virtualbox/7.0.14/Oracle_VM_VirtualBox_Extension_Pack-7.0.14.vbox-extpack
Download extension pack terminal output

2. Import the Extension Pack:

sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-7.0.14.vbox-extpack
import extension pack terminal output

3. Confirm the installation and allow the process to complete.

Successfully installed VirtualBox extension pack

Option 3: Install VirtualBox Using a .deb File

Another way to install VirtualBox on Ubuntu is to use the .deb file. The following steps explain how to do that.

Step 1: Download .deb File

To start the installation, download the .deb file from the VirtualBox website. Take the following steps:

1. Go to the VirtualBox Download page.

2. Click the Linux distributions link.

choosing the Linux distributions link

3. Find the download link for the current Linux version. In this example, it is Ubuntu 22.04.

Choosing Linux version

4. Click the link and wait for the download to finish.

VirtualBox downloading

Note where the file is saved, as it is needed in the next step. In this example, the file is downloaded to the Downloads directory.

VirtualBox in the Downloads directory

Step 2: Install .deb Package

To install the .deb package:

1. Navigate to the directory where the package is downloaded. In this case, it is the Downloads directory. Use the cd command:

cd ~/Downloads
cd /downloads terminal output

2. Use the dpkg command to install the .deb file from the Downloads directory. The syntax is:

sudo dpkg -i [archive-name].deb

In this example, the command is:

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

Step 3: Verify the Installation

Once the installation is completed, verify the installation by running the app:

virtualbox

The command has no output but launches the VirtualBox program.

Note: While this method is simple, it is inconvenient in the long term since it requires a complete reinstall for every update.

Getting Started With VirtualBox

Once installed, VirtualBox allows users to create and manage virtual machines. The software lets users run multiple guest operating systems concurrently on the host machine.

The basic menu items in VirtualBox include:

  • File:
    • New. Creates a new virtual machine. When selected, VirtualBox opens a wizard that guides users through creating a new virtual machine.
    • Add. Adds an existing virtual machine to the VirtualBox Manager.
    • Preferences. Configures VirtualBox settings such as general, input, and network settings.
  • Machine:
    • Start. Starts the selected virtual machine. Once a virtual machine is created or imported into VirtualBox, use this option to boot it up and start using it.
    • Pause. This option pauses the selected virtual machine. When users pause a virtual machine, its state is saved, and it temporarily stops executing. This is useful for temporarily suspending a virtual machine without shutting it down.
    • Reset. Resets the selected virtual machine.
    • Power Off. Powers off the selected virtual machine and saves the state.
  • Devices:
    • Optical Drives. Manages virtual optical drives attached to the selected virtual machine.
    • Shared Clipboard. This option enables or disables the shared clipboard. When enabled, text and files can be copied and pasted between the host operating system and the guest operating system running in the virtual machine.
    • Drag and Drop. Enables or disables drag and drop. When enabled, users can drag files and directories between the host operating system and the guest operating system.

These menu items vary depending on the version of VirtualBox and the operating system.

Create Your First Virtual Machine

VirtualBox's primary function is to install and run an operating system within another operating system by creating virtual machines. Take the following steps to create a virtual machine.

1. Launch the VirtualBox interface if not already launched:

virtualbox
Starting VirtualBox

2. Click the New button to create a new virtual machine. A dialog box opens.

3. Type the OS name. The Type and Version are filled out automatically based on the name. However, change them manually if needed.

choose machine name

4. In the same window, the system prompts you to select an ISO file to boot from. This ISO file can be obtained from the official website of the operating system you wish to install (e.g., Debian, Windows, etc.). Choose the file and click Next.

choose ISO image

Note: If you're interested in creating a Rocky or Kali Linux virtual machine, check out our in-depth guides:

5. Choose the username, password, hostname, and domain name. You can install Guest Additions in this step. Guest Additions are drivers and utilities that enhance the performance and usability of guest operating systems.

Configure guest OS

Once completed, click Next.

6. Allocate the base memory and the virtual CPU count. Make sure the sliders stay on the green side to ensure the allocated resources are within the recommended range. This step ensures optimal performance of both the host and guest operating systems.

Allocate RAM and CPU size

7. Mark the Create a Virtual Hard Disk Now checkbox, adjust the Disk Size slider, and click Next.

Set disk size

8. Check all the settings in the Summary section and click Finish. Once finished, the machine starts installing and configuring;

virtual machine starts

8. Once installation completes, a new virtual machine appears in the left column. Select it and click the green arrow Start button.

start-virtual-machine

A new window opens and boots up the virtual machine.

Note: VirtualBox also offers pre-built developer VMs that can be downloaded from the Oracle website. These VMs come pre-configured with a development environment, including the necessary tools, libraries, and frameworks to streamline the process of setting up a development environment.

Conclusion

After reading this article, you know three different methods to install VirtualBox on Ubuntu. You also learned how to create a virtual machine on VirtualBox.

Next, read this comparison of Virtualbox vs VMware.

Was this article helpful?
YesNo
Sara Zivanov
Sara Zivanov is a technical writer at phoenixNAP who is passionate about making high-tech concepts accessible to everyone. Her experience as a content writer and her background in Engineering and Project Management allows her to streamline complex processes and make them user-friendly through her content.
Next you should read
How to Install VirtualBox on CentOS 7
March 13, 2024

This guide explains how to install VirtualBox 6.0 on CentOS 7 directly from official Oracle repositories. Get...
Read more
How to Install Kali Linux on VirtualBox
March 28, 2024

Kali Linux is a Debian-derived Linux distribution designed for penetration testing. With over 600...
Read more
How to Install Apache Tomcat 9 on Ubuntu 18.04
July 2, 2019

Apache Tomcat is a free, open-source, lightweight application server used for Java-based web applications.
Read more
How to Install Wine 4 on Ubuntu 18.04
April 24, 2024

Wine is an application that lets you run Windows programs on a Linux system. Wine is similar to an emulator...
Read more