VirtualBox is a free and open-source hypervisor for x86 and x86-64 virtualization, which the Oracle Corporation develops. The software targets users wishing to create virtual environments for servers and desktops that allow users and administrations to run multiple guest operating systems on a single computer for either testing methods or production use. VirtualBox may be installed on Windows, macOS, Linux, Solaris, and OpenSolaris.
In the following tutorial, you will learn how to install VirtualBox on your Ubuntu 22.04 LTS Jammy Jellyfish system by importing the official virtual box repository and installing the most up-to-date version using the command line terminal. The extra benefit for users using this method is that you will receive them instantly from the VirtualBox repository when updates drop.
Table of Contents
First, before you begin, perform a quick update to your system to ensure all existing packages are up-to-date to avoid any conflicts during the installation of VirtualBox.
sudo apt update && sudo apt upgrade
Install Required Packages
The following dependencies will need to be installed to install VirtualBox successfully. Most of these packages would already be present on your system, but running the command can help ensure they’re installed.
sudo apt install wget apt-transport-https gnupg2 ubuntu-keyring -y
If you skip and encounter issues, return and just run the command.
Import GPG Key & Repository
Import the GPG Key
The first step in installing VirtualBox latest build is first to add the GPG key to verify the authenticity of the packages.
sudo wget -O- https://www.virtualbox.org/download/oracle_vbox_2016.asc | gpg --dearmor | sudo tee /usr/share/keyrings/virtualbox.gpg
Import VirtualBox Repository
The next step is to import the official repository from VirtualBox now.
echo deb [arch=amd64 signed-by=/usr/share/keyrings/virtualbox.gpg] http://download.virtualbox.org/virtualbox/debian jammy contrib | sudo tee /etc/apt/sources.list.d/virtualbox.list
Now, update your repository list to reflect the new additions.
sudo apt update
With the setup complete, execute the installation command to install VirtualBox.
sudo apt install virtualbox-6.1 -y
Optionally, ensure that the VirtualBox installation was pulled directly from the source repository and check the current version installed using the apt-cache policy command.
apt-cache policy virtualbox-6.1
Confirm if VirtualBox was installed successfully. Check the current status as follows.
systemctl status vboxdrv
If by chance this has not been activated, which by default it is when installing, use the following command that will activate the service and enable it to be active from system boot.
sudo systemctl enable vboxdrv --now
How to Launch VirtualBox
VirtualBox can be launched immediately from your terminal if open with the following command.
However, many users on desktops would use the following desktop path.
Acitivities > Show Applications > Virtualbox
Once open, you will arrive at the main screen, where you can begin to create virtual machines. It is very similar for users coming from VMWare, and users new to virtual machines should check out the VirtualBox user manual.
How to Update/Upgrade VirtualBox
Updating VirtualBox can be done using the command line terminal with the following standard commands you would have used at the start of the tutorial to check your system for updates.
sudo apt update && sudo apt upgrade
Most newer Linux users usually set up some automatic updates or rely on the notifications from their desktop especially coming from a Windows-type background. You should always check using the terminal at a minimum once a week to ensure you are not missing any updates. The terminal method will grab all available updates, ensuring your system is up-to-date.
How to Remove/Uninstall VirtualBox
The removal of VirtualBox is straightforward. For users that want to remove the software entirely, use the following command.
sudo apt autoremove virtualbox* --purge -y
Note that this will delete all data, including all database data added with the –purge flag. Do not use the purge end flag if you wish to keep the data.
Next, remove the repository sources file using the following command.
sudo rm /etc/apt/sources.list.d/virtualbox.list
Optionally, you can remove the GPG key if you prefer.
sudo rm /usr/share/keyrings/virtualbox.gpg
Comments and Conclusion
Overall, out of the many virtual machine software on the market, VirtualBox is one of the top players supplying an excellent selection of host and client combinations such as Windows from XP onwards, any Linux level 2.4 or better, Windows NT, Server 2003, Solaris, OpenSolaris, and even OpenBSD Unix.