Hints on package removal for Debian-based systems

The following hints are on how to identify packages that can be removed from
a Debian-based system.
My motivations on trimming the system are optimal use of resources, the less
packages the better from my point of view, but never less than needed. As
well as reduce potential attack vectors.

- Delete downloaded packages cache:
 $ sudo apt-get clean
- Remove unused packages:
 $ sudo apt-get autoremove --purge
- Find obsolete packages:
 $ dpkg -l | grep obsolete
 $ aptitude search '?obsolete'

Depending on the packages and their dependencies make sure which ones you
really wanna purge;

- Find dummy packages:
 $ dpkg -l | grep dummy

Make sure which packages you really want to purge depending on their
dependencies;

- Find transitional packages which may be purged:
 $ dpkg -l | grep -i transitional
- Identify and purge orphan packages, repeat until no more packages to purge:
 $ sudo aptitude purge `deborphan`

Make sure deborphan it’s installed (sudo aptitude install deborphan)

- Find packages that are not required by any manually installed package:
 $ aptitude search '?garbage'
- Discover files from configured but not installed packages:
 $ aptitude search '?config-files' | awk {'print $2'}
- Guess unused packages:
 $ deborphan --guess-all

Make sure you don’t need them before removing packages.

– When removing packages purge them to also remove configurations:

 $ sudo aptitude purge packageName

– Purge removed packages:

# aptitude purge '~c'

Posted

in

by

Comments

Leave a Reply