How to install VirtualBox from command line?

I am a newbie. For some reasons, I need to install Virtualbox. I see that I can easily install it using the Software Center, but I trust most the apt-get install way, because I find it safer, less buggy, and it helps me accommodate more with the Terminal.

So, my question is the following: is there a way to install VirtualBox using the command line? I would prefer something easy, like apt-get install not unzipping, archiving, etc, because I still don't know how to do these in the Terminal.


Open a terminal and execute:

sudo apt-get install virtualbox 

which should work.

Once you have installed it you probably want to install guest additions in the guest OS.

Also you probably want the extension pack which you can get from here:

https://www.virtualbox.org/wiki/Downloads

Make sure you get the correct version.

As of Xenial 16.04, you can also get the extension pack from the Canonical repositories. Go to the terminal and execute:

sudo apt install virtualbox-ext-pack 

Therefore, as of Xenial 16.04, you should be able to get virtualbox and the extension pack by typing the following:

sudo apt install virtualbox virtualbox-ext-pack 

Following the instructions on your screen.

To install the user interface to manage your virtual boxes use this command

sudo apt install virtualbox-qt

If you want to have a latest version of VirtualBox, check this: https://www.virtualbox.org/wiki/Linux_Downloads

Add one of the following lines according to your distribution to your /etc/apt/sources.list:

deb http://download.virtualbox.org/virtualbox/debian xenial contrib
deb http://download.virtualbox.org/virtualbox/debian trusty contrib
deb http://download.virtualbox.org/virtualbox/debian precise contrib

Alternatively, you can use add-apt-repository to add to your /etc/apt/sources.list:

sudo apt-add-repository "deb http://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib"

Add secure key:

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

- or for Debian 8 ("Jessie") / Ubuntu 16.04 ("Xenial") and later:

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

Install VirtualBox:

sudo apt-get update
sudo apt-get install virtualbox-5.2

You can use

apt-cache search virtualbox

to search for packages related to "virtualbox".

Among others this finds a package virtualbox. Use

apt-cache show virtualbox

to get more information about that package.

As the description sounds like what you want use

sudo apt-get install virtualbox

to install the package.


Run these commands to install Virtualbox 5.0.

sudo apt-add-repository "deb http://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib"
wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
sudo apt-get update
sudo apt-get install virtualbox-5.0 dkms 

dkms (optional): "Ubuntu/Debian users might want to install the dkms package to ensure that the VirtualBox host kernel modules (vboxdrv, vboxnetflt and vboxnetadp) are properly updated if the linux kernel version changes during the next apt-get upgrade."