Purge old packages from Linux

For deb based distributions like Debian, Ubuntu, it is advisable to purge old packages (have status rc, r=removed, c=config).

List all removed packages that have config files:

dpkg -l | awk '/^rc/ { print $2 }'

Remove all old and unnecessary packages using apt-get:

apt-get purge $(dpkg -l | awk '/^rc/ { print $2 }')
apt-get autoremove

Can also be done with dpkg