Can anyone help me remove VirtualBox?

I am running 12.04.

  • 3
    open ubuntu software center an remove from there....
    – penreturns
    Sep 18, 2012 at 3:48
  • 4
    Try this sudo apt-get purge virtualbox*
    – blade19899
    Sep 18, 2012 at 7:00

7 Answers 7


To remove VirtualBox, I actually recommend running this command and not replacing * with anything (just run it exactly like so):

sudo apt-get remove virtualbox-\*

If you want to remove global configuration files too (this does not remove your virtual machines), run exactly this instead:

sudo apt-get purge virtualbox-\*

That method is OK, but this way may be more thorough.


  • You may have multiple VirtualBox-related packages installed. Assuming your machine no longer needs to be a VirtualBox host or guest machine, all these packages can go. For example, on the 11.10 box I'm using right now, there are 18 such packages available for installation (your machine might have some or even all of them, or other packages from your release or a PPA):

    virtualbox                      virtualbox-ose
    virtualbox-dbg                  virtualbox-ose-dbg
    virtualbox-dkms                 virtualbox-ose-dkms
    virtualbox-fuse                 virtualbox-ose-fuse
    virtualbox-guest-additions      virtualbox-ose-guest-dkms
    virtualbox-guest-additions-iso  virtualbox-ose-guest-utils
    virtualbox-guest-dkms           virtualbox-ose-guest-x11
    virtualbox-guest-utils          virtualbox-ose-qt

    Some are probably already not installed, and some may be removed automatically as a consequence of removing others, but some would not.

  • apt-get accepts * characters and treats them as part of a regular expression. This is in some ways similar to the way a command-line shell processes *. When used in an apt-get command, virtualbox-\* (see below for why the \, which is not being used as regular expression syntax) actually matches any package whose name contains virtualbox.

    (Be careful with this as applied to packages with shorter names! For example, wine\* matches every package with win--not just wine--anywhere in its name.)

    So you don't have to manually expand *. It can stay, and it will catch the various related packages as described above, as well as packages with explicit versions in their names as discussed there.

  • However, the shell itself, which executes apt-get with the command-line arguments you specify, also accepts wildcards. Therefore, you should escape the wildcard (and one way to do that is with a \ character before the *). Otherwise, if your expression matches a file or folder in that current location, the shell would give its name to apt-get, which would be wrong.

What does purge do here?

purge removes global configuration files only. It does not remove virtual machines, so it's safe to use. However:

  • It also doesn't remove most of the settings you might think it would. Remember, it removes global configuration files only. It does not remove any configuration files created by users that exist in their home directories and define how VirtualBox is configured for them.
  • Configuration files rarely take up a lot of space. If your goal is to free space but you think you may want to use VirtualBox again, you might prefer not to use purge.

Also, please note: apt-get --purge remove ... is the same as apt-get purge ....

  • Thank you, this is an exemplary answer! Very detailed written which makes it helpful for inexperienced users such as me :) Sep 7, 2013 at 8:19
  • I tried this but I get this: E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?
    – medo ampir
    Apr 28, 2014 at 18:06
  • 1
    @medoampir Make sure you're not running any other package management software at the same time. This includes the Software Center, Software Updater (Update Manager in older versions of Ubuntu), Synaptic, gdebi, or currently-running package management commands like apt-get, aptitude, and dpkg. Make sure no other currently logged-in users (if any) are running any such software. This may include non-administrators, since by default they may allow the Software Updater to install updates. If that still doesn't fix it, see this question about the problem. May 2, 2014 at 18:42
  • Wonderful explanation...!! @Eliah Kagan Feb 8, 2016 at 10:50
  • Don't forget to remove per-user configuration afterwards (rm -rf ~/.config/VirtualBox)
    – fnkr
    May 7, 2016 at 18:13

Open the terminal (Ctrl+Alt+T) and issue the command:

sudo apt-get purge virtualbox-*

Replace * with the version of VirtualBox installed on your system (e.g. sudo apt-get purge virtualbox-4.2).

Alternatively, you can make use the auto-complete feature in the terminal by hitting the Tab key after typing virtualbox.


If you have Oracle VM VirtualBox and ubuntu 15.04

  1. sudo dpkg -l | grep virtualbox

which shows something like this.

ii virtualbox-4.2 4.2.6-82870~Ubuntu~quantal amd64 Oracle VM VirtualBox

  1. now from above command you can determine which version of virtual-box is installed on your machine.After this type these commands in your terminal,Just replace the 4.2 with your version of VirtualBox.

    sudo apt-get purge virtualbox-4.2 virtualbox-qt


For me nothing helped but this

$ sudo /opt/VirtualBox/uninstall.sh

vboxdrv.sh: Stopping VirtualBox services.
VirtualBox 5.1.22 r115126 has been removed successfully.

$ sudo rm -rf /opt/VirtualBox/

16.04 and later

Open the terminal and type:

sudo apt remove virtualbox unity-scope-virtualbox ^virtualbox-

How to uninstall Oracle VirtualBox

If you installed VirtualBox from the Oracle website find your VirtualBox version as follows:

sudo apt install aptitude
aptitude search virtualbox\*

The latest version of VirtualBox that has Oracle VM VirtualBox on the same line with it is the package you have installed. If you have the latest version of Oracle VirtualBox installed, it is named virtualbox-5.1.

Verify that this version of Oracle VirtualBox is currently installed.

dpkg-query -s virtualbox-5.1    

Uninstall Oracle VirtualBox using a command that looks like this:

sudo apt remove VirtualBox-5.1  

If you have a different version of Oracle VirtualBox installed replace VirtualBox-5.1 in the above command with your VirtualBox version.


or use next command if you install vmbox from script:

sudo ./VirtualBox-4.1.4-74291-Linux_amd64.run remove

Use this command to completely remove the package:

sudo apt-get purge virtualbox-\*      

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .