How to uninstall VirtualBox in 12.04?
Can anyone help me remove VirtualBox?
I am running 12.04.
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 ...
.
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
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
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.