install virtualbox on ubuntu code example

Example 1: remove virtualbox from ubuntu

#Uninstall VirtualBox first.

sudo apt-get remove --purge virtualbox 
#Run these commands to delete all virtual machines and settings and Virtual Hard Drives:

sudo rm ~/"VirtualBox VMs" -Rf
sudo rm ~/.config/VirtualBox/ -Rf
#If you want to install it again. Run this command:

sudo apt-get install virtualbox
#Additionally, check:

sudo ps aux | grep -i "vbox"
#Kill any "ghost" processes you may think are relevant.

sudo pkill VBox*

Example 2: how to install virtualbox in ubuntu

wget –q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
#use codename of your linux version,for my case focal is codename for 
#ubuntu 20.04.1
sudo add-apt-repository "deb http://download.virtualbox.org/virtualbox/debian focal contrib"
#you can check codename of your system using command below
lsb_release -cs
sudo apt update && sudo apt install virtualbox-6.1

Example 3: virtualbox ubuntu

yum install VirtualBox-6.1