How to install VirtualBox from command line?

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.