Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

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
For the latest Oracle version 4.3 also see:… 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 41 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:

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
Ubuntu 15.04 cloud image - no installation candidate found for virtualbox. This worked last week. Here is a paste: 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:

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

deb vivid contrib
deb utopic contrib
deb trusty contrib
deb saucy contrib
deb raring contrib
deb quantal contrib
deb precise contrib
deb lucid contrib non-free

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

sudo apt-add-repository "deb vivid contrib"

Add secure key:

wget -q -O- | sudo apt-key add -

Install VirtualBox:

sudo apt-get update
sudo apt-get install virtualbox-5.0
share|improve this answer
Curious if you can elaborate on why this is preferable to sudo apt-get install virtualbox and why you can't just run sudo apt-get install virtualbox-5.0? – Luke 2 days ago

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.

if [ $(dpkg-query -W -f='${Status}' virtualbox 2>/dev/null | grep -c "ok installed") -eq 0 ];
    if [ $(apt-cache search virtualbox | grep virtualbox) ];
        apt-get install -y virtualbox
        apt-add-repository "deb vivid contrib"
        wget -q -O- | apt-key add -
        apt-get update
        apt-get install -y virtualbox-5.0

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


share|improve this answer

Run these commands to install Virtualbox 5.0.

sudo apt-add-repository "deb vivid contrib"
wget -q -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.