Simply get rid of your old crufty packages (one liner)

Kristian Erik Hermansen kristian.hermansen at
Mon Aug 20 03:39:24 UTC 2007

This is kind of a hack for people who have upgraded from release to
release and have lots of old package cruft lying around.  Basically,
over time, packages will be removed from Ubuntu's repositories and/or
become unmaintained externally in other repositories.  To deal with
this, and since I have been upgrading like this from Warty -> Hoary ->
Breezy -> Dapper -> Edgy -> Feisty -> Gutsy merely using 'aptitude
update && aptitude dist-upgrade', I had much lying around :-)

This is the one liner...with no error checking or anything, but you
get the idea.  Use 'remove' to be safe, rather than 'purge', or else
you will lose any configs you may want to keep for some reason...

$ sudo -i
# while true; do aptitude -s reinstall ~i 2>&1 | grep "able to locate
file for the" | aptitude -y remove $(awk '{print $10}'); done

Eventually, you will return to a clean system with no crufty packages.
 Watch it as it goes, so that you aren't removing anything
unimportant.  You will notice that packages like mozilla got renamed
to mozilla-browser, so it will be removed in this case.  BE CAREFUL of
things like this!  But I assume most of you will just take this, run
it, and go 'oh damn, I forgot I had that package junk lying around for
so long?!?!?!'...
Kristian Erik Hermansen

More information about the ubuntu-server mailing list