Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

OK, I a 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 blahblah" 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 Virtual box using a command line? I would prefer something easy, like "apt-get install etc" not unzipping, archiving, etc, because this kind of things I still don't know how to do from inside the Terminal.

Thank you in advance for your help!

share|improve this question
2  
For the latest Oracle version 4.3 also see: askubuntu.com/questions/41478/… which includes CLI instructions. Note that there is no repository for 13.10 yet but the 13.04 version should work too. – Takkat Oct 28 '13 at 11:57
    
@Takkat - For now, is no problem for me if there is no repository for 13.04 as I don't run the latest version. :-) But it is good that you mentioned it. It might help other users. – Cristiana Nicolae Oct 28 '13 at 13:31
up vote 40 down vote accepted

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.

share|improve this answer
    
@ Warren Hill - Thanks a lot! To be frank, I have used the easier path - just sudo apt-get install virtualbox - without looking for the correct version. Till now, it works fine. But next time when I will need to install it, I'll be wiser and I'll follow your advice. :-) – Cristiana Nicolae Oct 28 '13 at 14:16
1  
Ubuntu 15.04 cloud image - no installation candidate found for virtualbox. This worked last week. Here is a paste: pastebin.com/dYkSY3jc The virtualbox meta-package is not available on my Ubuntu15.04 cloud images so I have to add the repo and update first. – spyderdyne Nov 17 '15 at 19:25
    
it work, thanks – meow meo Mar 23 at 9:46

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 vivid contrib
deb http://download.virtualbox.org/virtualbox/debian utopic contrib
deb http://download.virtualbox.org/virtualbox/debian trusty contrib
deb http://download.virtualbox.org/virtualbox/debian saucy contrib
deb http://download.virtualbox.org/virtualbox/debian raring contrib
deb http://download.virtualbox.org/virtualbox/debian quantal contrib
deb http://download.virtualbox.org/virtualbox/debian precise contrib
deb http://download.virtualbox.org/virtualbox/debian lucid contrib non-free

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 vivid contrib"

Add secure key:

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

Install VirtualBox:

sudo apt-get update
sudo apt-get install virtualbox-5.0
share|improve this answer

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.

share|improve this answer

My Ubuntu-15.04 cloud images are missing the virtualbox package from the included sources. Kostanos' method works, but since virtualbox is a meta-package with multiple versions depending on the release you are running you may need to specify a particular version.

Here is a script that checks for an installation candidate, installs the repo if there isnt one, then updates the package lists and installs it for you. As noted in his answer, be sure to change "vivid" to your release name.

#!/bin/bash
if [ $(dpkg-query -W -f='${Status}' virtualbox 2>/dev/null | grep -c "ok installed") -eq 0 ];
  then
    if [ $(apt-cache search virtualbox | grep virtualbox) ];
      then
        apt-get install -y virtualbox
      else
        apt-add-repository "deb http://download.virtualbox.org/virtualbox/debian vivid contrib"
        wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | apt-key add -
        apt-get update
        apt-get install -y virtualbox-5.0
    fi
fi

I had to write this for a Mythos project automation so I thought I would share.

Thanks.

share|improve this answer

Run these commands to install Virtualbox 5.0.

sudo apt-add-repository "deb http://download.virtualbox.org/virtualbox/debian vivid 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
share|improve this answer

protected by Community Feb 19 at 3:55

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.