Remove apps with style: nuke it from orbit

function nuke() { if [ $(whoami) != "root" ] ; then for x in $@; do sudo apt-get autoremove --purge $x; done; else for x in $@; do apt-get autoremove --purge $x; done; fi }
You can't stand programs x, y, and z. Remove all trace of their existence by adding this function to your config. It will remove the cruft, the settings, and such and such. This function doesn't even give a damn about you trying to remove programs that don't exist: it'll just for loop to the next one on your hit list.
Sample Output
hello@goodbye:~$ nuke amarok emacs vim
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Couldn't find package amarok
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Couldn't find package emacs
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Couldn't find package vim
hello@goodbye:~$

1
By: ruinbox
2009-03-25 23:21:21

What Others Think

this can be shortened a lot. sudo aptitude purge $@ should accomplish the same thing. Aptitude throws an error on packages not found, as opposed to stopping like apt. Additionally, the default behaviour of aptitude is to autoremove packages, so that libraries installed for something you removed will go away.
clockworkavian · 507 weeks and 2 days ago
Wow thanks. I did not know that about aptitude. Well that settles it then. Move along, nothing to see here.
ruinbox · 507 weeks and 1 day ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

Considering A New Car?

You should consider a Tesla. Get 6 Months Free Supercharging.

Free Supercharging

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: