I recently had to make some updates to my VirtualBox and Vagrant installations and decided to completely uninstall VirtualBox to reinstall the newest version to start fresh. I am creating this post as a future reference (mostly for the home folder info) but also to share.
Step 1: Completely Remove All VirtualBox Packages and Folders from Ubuntu
If you are interested in checking out all of the package versions on your system before uninstalling, you can run
dpkg -l | grep virtualbox
To uninstall and remove all packages, run
sudo apt-get remove virtualbox* --purge
This command does a couple of things:
1. Identifies virtualbox packages to ensure all versions are targeted by using the asterisk wildcard.
2. The purge option also triggers removal of any configuration files.
To also remove all of the VMs stored in the home directory, move to the next step.
Step 2: Remove all VMs from Home Directory
sudo rm command with
-rf is a very destructive command. Always pay attention to what your command is doing before hitting enter.
ANOTHER NOTE: This will remove all VMs that have been installed to the default home folder location. If you don’t want to remove VMs, don’t complete this step.
Because “sudo rm -rf” is destructive, check to see if you even need to use the command by locating the files and attempting to delete without sudo.
1. Browse to your home directory (you can usually just type cd and hit enter).
3. If you see the directory “VirtualBox VMs”, you can try to delete without sudo first
rm -rf ./"VirtualBox VMs" (you need to use double quotes around the folder name because of the space). If you run into file permission problems, you can try to take ownership and then try deleting without sudo
sudo chown `whoami` -R ./"VirtualBox VMs" and then try
rm -rf ./"VirtualBox VMs". If all else fails, and it makes sense, use sudo:
sudo rm -rf ./"VirtualBox VMs".
4. Remove config files from home directory. Technically, when running your apt-get remove with purge, all config files should have been targeted, but it is good to check anyway. From your home directory, change into your .config folder
cd .config and look for a folder named VirtualBox. Try removing without sudo at first (since it is located in your home folder, you should have the ability to do so)
rm -rf ./VirtualBox.
At this point, all of your previous VirtualBox installation should have been removed.