VirtualBox is a very popular virtualization tool used to run different operating systems on Ubuntu systems. VirtualBox provides the ability to run Windows, BSD, Debian, CentOS, Kali even Ubuntu operating systems on Ubuntu. VirtualBox can be installed in different ways onto a Ubuntu system. In this tutorial, we will learn.
Install VirtualBox via Ubuntu Repository
The first and easiest way is installing VirtualBox on Ubuntu by using the Ubuntu repositories. VirtualBox software is provided by Ubuntu. But the provided VirtualBox version is generally older than currently provided one. So before installing VirtualBox from the Ubuntu repositories via command-line apt command, it is a good idea to check version information about the VirtualBox package with the apt show
command like below.
$ sudo apt show virtualbox

Then we can install the VirtualBox with the following command.
$ sudo apt install virtualbox

Install VirtualBox via VirtualBox Deb Package
Oracle VirtualBox also provides the deb packages of VirtualBox for Ubuntu. This deb package can be also used for distributions like Mint and Kali. The deb package can be downloaded from the following link.
https://www.virtualbox.org/wiki/Linux_Downloads

As we can see the VirtualBox deb packages are provided for different versions of the Ubuntu. In this case, we will select the Ubuntu 18.04/18.10/19.04
and download it with the wget command like below. Also, the browser can be used for download.
wget https://download.virtualbox.org/virtualbox/6.0.14/virtualbox-6.0_6.0.14-133895~Ubuntu~bionic_amd64.deb

We will used the dpkg
command in order to install downloaded virtualbox-6.0_6.0.14-133895~Ubuntu~bionic_amd64.deb
deb package.
$ sudo dpkg -i virtualbox-6.0_6.0.14-133895~Ubuntu~bionic_amd64.deb

Install VirtualBox via VirtualBox Official Repository
We can also use the official Oracle VirtualBox repositories for Ubuntu. Before installing the VirtualBox we will add the Oracle VirtualBox repository to our Ubuntu system. The first step is adding the GPG key of the Oracle VirtualBox repository to our trusted repository list. We will use the following wget command to download the GPG key and add it to the apt repository.
$ wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
The second step is adding the repository information to the /etc/apt/sources.list
which can be done with the add-apt-repository
command like below.
$ sudo add-apt-repository "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib"

We can check the sources.list file with the following command.
$ tail -10 /etc/apt/sources.list

The last step is starting the installation with the apt install
command. We will install the virtualbox
package as below.
$ sudo apt install virtualbox-6.0

Install VirtualBox Extension Package
VirtualBox provides an extension package in order to add some features like RDP to Gues, VM Disk AES Encryption, etc. We can list this extension package information below.
$ apt show virtualbox-ext-pack
We will first download the extension pack with the following command. The VirtualBox extension pack file is named as Oracle_VM_VirtualBox_Extension_Pack-6.0.0.vbox-extpack
.
$ wget https://download.virtualbox.org/virtualbox/6.0.0/Oracle_VM_VirtualBox_Extension_Pack-6.0.0.vbox-extpack

We will use the VBoxManage
command in order to load or install the extension pack. This action also requires root privileges which can be provided with the sudo
command.
$ sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-6.0.0.vbox-extpack

We have to accept the license like below. We will input Y
in order to accept the license. After that the extension pack install will start the installation progress will be shown like 0%..10%..20% etc.

Start VirtualBox
We can start VirtualBox in different ways. From GUI we can use the Application menu where it is stored in System category like below.

Alternatively, we can start the VirtualBox from the command line with the virtualbox
command like below.
$ virtualbox

Uninstall/Remove VirtualBox From Ubuntu
We can uninstall the installed VirtualBox in different ways. One of the most convenient ways is using the apt
command from the command line. Uninstall operation requires the root privileges so we will use the sudo
.
$ sudo apt remove virtualbox
