Enter your email address below and subscribe to our newsletter

How to Install VirtualBox in Ubuntu

Learn how to install VirtualBox in Ubuntu using 3 simple methods.

Share your love

VirtualBox is the easiest way you can install and use multiple virtual machines. The best part of using VirtualBox is it is free and available for all the major platforms including Linux, Windows and macOS.

So in this tutorial, I will walk you through 3 simple ways to install VirtualBox in Ubuntu:

  • Using the default repository of Ubuntu (easy and recommended)
  • Using the .deb package of VirtualBox
  • Using the Oracle repository (latest version + auto update)

In the end, I will also share how you can remove VirtualBox, irrespective of what method you choose from these three.

Let’s start with the first installation method.

1. Using the default repository

Note: Using this method, you will get a slightly older version of VirtualBox. If you want the latest release, skip to the next method.

By far, this is the easiest way you can install VirtualBox on Ubuntu. You have two options here: You can either use the software centre or use the command line.

I’ll show you both and start with the command line as I find it a more convenient and straightforward way to do things.

To install VirtualBox on Ubuntu using the command line, all you have to do is execute the following command:

sudo apt install virtualbox

That’s it!

If the command line sounds too complicated and you are looking for something easier, then you can use the Ubuntu software centre to install VirtualBox on Ubuntu.

To install VirtualBox on Ubuntu using the software centre, you need to follow two simple steps:

  • Search for VirtualBox in software centre
  • Hit the Install button and enter the user password
Install VirtualBox using software centre on Ubuntu

2. Using the deb package

Note: While this method gives you the latest release of VirtualBox, the only way to upgrade it to the next release is to reinstall it. If you want to use the latest version with auto-update, then skip to the next method.

This is the official way of installing VirtualBox on Ubuntu where you download the .deb file for VirtualBox and install it on your system.

To install VirtualBox in Ubuntu through the .deb package, head over to the official download page of the VirtualBox and download the .deb file for your Ubuntu release:

Download the deb file for installing virtualbox on ubunt

Once you are done downloading the .deb file, open your terminal and change your directory to Downloads using the following:

cd ~/Downloads

Next, execute the following command to install the .deb file of VirtualBox on Ubuntu:

sudo apt install ./virtualbox*.deb
Install virtualbox in Ubuntu through the deb file

The reason why I recommend this method is it is the best of the both methods shown above. You get the latest version of VirtualBox and it will be updated automatically when you perform a system update.

This method involves adding an Oracle repository to your system by which the packages installed through that repository will automatically be updated at every system update.

First, add the key to the repository by which the packages will be verified using the following command:

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

Next, add the VirtualBox repository to your system by executing the following command:

sudo add-apt-repository "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib"

Now, update the repository index and install VirtualBox on Ubuntu using the following command:

sudo apt update && sudo apt install virtualbox-7.0

That’s it!

How to uninstall VirtualBox from Ubuntu

If you want to uninstall VirtualBox from Ubuntu, then, it can easily be done through a single command (still I’ll show you two commands to give you a choice).

To remove VirtualBox from Ubuntu without removing the configuration files, use the following:

sudo apt remove virtualbox virtualbox-*

To remove VirtualBox from Ubuntu including all the configuration files, use the given command:

sudo apt remove --purge virtualbox virtualbox-*

Optionally, if you want to remove additional settings, configurations and virtual hard drives, then you can use the given two commands one by one:

sudo rm ~/"VirtualBox VMs" -Rf
sudo rm ~/.config/VirtualBox/ -Rf

That’s it!

Wrapping Up…

In this tutorial, I went through how you can install VirtualBox on Ubuntu in 3 different ways. I find the third method most useful as it automatically updates VirtualBox with every system update. At the end, I’ve also mentioned how you can uninstall VirtualBox from Ubuntu.

I hope you will find this guide helpful. If you have any queries or suggestions, leave us a comment.

Share your love
Kabir
Kabir

A tech journalist whose life revolves around networks.

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!