August 21, 2011

List and remove optional packages on Debian

First, install aptitude:
apt-get update && apt-get install -y aptitude

That's how you list optional (i.e. unnecessary) packages that are already installed on your system with aptitude:
aptitude search '?installed?priority("optional")'|sed -ne 's/^i [ A] \([^ ]*\).*$/\1/p' | tr '\n' ' ' | sort -u|fold -s>optional.txt

You may also want to delete them:
apt-get purge `cat optional.txt`

Be careful! Manually check optional.txt in order to make sure any needed packages (like openssh-server) won't get removed.
Once again, be careful! The package names you leave in optional.txt are the ones to be removed! Basically, the optional.txt file is the list of packages that will be purged from your system.

These links had helped me a lot:

No comments: