How to uninstall VirtualBox in 12.04?
Solution 1
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.
Explanation
-
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 virtualbox-guest-x11
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 anapt-get
command,virtualbox-\*
(see below for why the\
, which is not being used as regular expression syntax) actually matches any package whose name containsvirtualbox
.(Be careful with this as applied to packages with shorter names! For example,
wine\*
matches every package withwin
--not justwine
--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 toapt-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 ...
.
Solution 2
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
.
Solution 3
If you have Oracle VM VirtualBox and ubuntu 15.04
sudo dpkg -l | grep virtualbox
which shows something like this.
ii virtualbox-4.2 4.2.6-82870~Ubuntu~quantal amd64 Oracle VM VirtualBox
-
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
Solution 4
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.
Solution 5
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/
Related videos on Youtube
helongvae
Updated on September 18, 2022Comments
-
helongvae almost 2 years
Can anyone help me remove VirtualBox?
I am running 12.04.
-
penreturns almost 12 yearsopen ubuntu software center an remove from there....
-
blade19899 almost 12 yearsTry this
sudo apt-get purge virtualbox*
-
-
king_julien almost 11 yearsThank you, this is an exemplary answer! Very detailed written which makes it helpful for inexperienced users such as me :)
-
medo ampir about 10 yearsI 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?
-
Eliah Kagan about 10 years@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
, anddpkg
. 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. -
Manisha over 8 yearsWonderful explanation...!! @Eliah Kagan
-
fnkr about 8 yearsDon't forget to remove per-user configuration afterwards (
rm -rf ~/.config/VirtualBox
) -
Anderson Marques over 6 yearsThank you! I've did not know more what to do. Worked just fine!