Install VirtualBox on Ubuntu 22.04

Download VirtualBox’s Repo GPG Key

wget -O- https://www.virtualbox.org/download/oracle_vbox_2016.asc | sudo gpg --dearmor --yes --output /usr/share/keyrings/oracle-virtualbox-2016.gpg

Add VirtualBox Repo to Ubuntu 22.04

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

Run System Update

sudo apt update

Check the output of the following command, and look for … download.virtualbox …
If everything is correct, you should find a line in the output containing a string like the one I have made in bold.

Install VirtualBox
sudo apt install virtualbox-7.0
Install VirtualBox Extension Pack. To verify the exact version of the installed locally VirtualBox, you can use vboxmanage, a build-in VirtualBox’s command:
vboxmanage -v | cut -dr -f1

You must then download the Extension Pack with the same version.

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

Install the extension

sudo vboxmanage extpack install Oracle_VM_VirtualBox_Extension_Pack-7.0.6.vbox-extpack

verify the installed VirtualBox’s extension pack version by running the following:

vboxmanage list extpacks

Add User to vboxusers Group

sudo usermod -a -G vboxusers $USER

Now perform a reboot. After login, check that you are in the vboxusers group with this command:

groups $USER