Posts Tagged ‘Things that Annoy Me’


Uninstalling .deb Packages

29 March, 2009

.deb packages, for the uninitiated, are functionally equivalent to .exe’s in Windows. You download them and then run them and they install software, drivers, etc on your computer. They are somewhat more convenient than using apt-get in many situations and they often seem friendlier to newcomers. But beware, the .deb has a dark side.

Just like with apt-get, .deb’s each have a unique package name, and you need to know this to uninstall them. Unlike apt-get, there is no handy-dandy GUI equivalent to provide you with a list of packages currently installed should you forget this name. So, if you want to uninstall a .deb file but can’t remember the exact package name, be prepared to do some digging.

The first, fastest, and probably most painless way may seem a little unintuitive; download the package again. Go back to where you got it, download it again, and open it with gdebi package installer. It will show the package name along with various other tidbits of information. Once you have the package name you can delete the newly downloaded file, and then go seek and destroy the installed version. If this option is available to you, do it- it will save you many a headache. However, there may be times when it is not; if you don’t remember where you got it or it’s no longer available, etc. Don’t worry, it’s still possible to uninstall the file, I just can’t guarantee that you won’t want to kill yourself by the time it’s done.

Second method is to run a wildcard search using dpkg. This is also fairly painless, but it only works if the package name is somewhat obvious- which they aren’t always. The command to use:

dpkg -l '*keyword*'

Where keyword is any word or bit of word that might be in or close to the package name. Say I wanted to uninstall Open Office: a good keyword here would be open. The list of packages that comes up is pretty long, but Open Office is indeed there. You can narrow it down more but you risk accidentally cutting out the package you want. So keep your keywords as basal as possible.

If after running a wildcard search you still have not found your package name you will need to get somewhat medieval and search the installed packages by hand. It’s tedious, but there are a few tricks to  speed it up. If you think you know the first letter of the package, you can use a permutation of the previous command to narrow your list:
dpkg -l 'x*'
Where  x is your letter of choice.

You can also search through the packages using a semi-gui called aptitude. In your terminal:
gksudo aptitude
While not exactly intuitive, aptitude at least separates the installed packages into categories. The first place to check is the upper-level category “Obsolete and Locally Created Packages”. Chances are good your package is in there, but if it’s not you’ll need to sift through the other categories to find it.

Okay, so, assuming you haven’t just chucked your computer out the window by now, you probably have your package name. Now you can finally delete it! This may be a bit anticlimactic, but geekdom isn’t exactly known for edge-of-your-seat thrills. Here’s the command to nuke that son of a bitch:
sudo dpkg -r package

The whole process of uninstalling .deb’s is really quite annoying and I’m surprised some programmer hasn’t come up with a little tool to at least search packages efficiently. In all honestly, probably the best way to handle this is to keep a text file with the names of all packages you install via .deb. It’s inconvenient, but should the time come to delete the file you will be very happy you did it.