What is Et cetera?...
Merriam-Webster: Main Entry: et·cet·era Pronunciation: \et-ˈse-tə-rə, -ˈse-trə also it-, ÷ek-, ÷ik-\ Function: noun Date: 1597 1 : a number of unspecified additional persons or things 2 plural : unspecified additional items : odds and ends
Let's think about that. /etc/ is full of random junk. It's pretty much the configuration for your whole system. Where do you configure defaults for the xxxx app? Did you check in /etc/? It's probably there.
How does /etc/ management work? Well... I'm not an expert but I do have some understanding. It goes something like this. This is of course in extreme brevity.
When you alter a config the system will no longer manage it magically. When you remove a package, that file should not be removed with it. What you can potentially be left with is a big mess of old configs. Is this a problem? Not on todays hardware really.
However, if you know me then you know where I'm going. The package management system is actually VERY smart. It keeps track of these files. If you didn't purge the package, it remembers that you didn't destroy configs. It also keeps track of the original hash of the config meaning it knows if you changed the config.
This means something to us phychos that freak out if we have more than clutter than we need. Let's get to why I LOVE Ubuntu. To my knowledge, this applies to any dpkg managed system.
We can use dpkg to get a list of all packages that were either installed or removed. We can then parse that list for anything that was installed then removed (ie. not purged). Then we can use dpkg again to purge any packages that have not yet been purged.
In one word:
dpkg --purge $(dpkg --get-selections | awk '$2 == "deinstall" { print $1 }')
In more than one word:
dpkg --get-selections - This will get a list of all packages that were selected. "install" means that you installed this package. "deinstall" means this package was installed and then removed. Blank means it was either never installed or purged from the system.
awk '$2 == "deinstall" { print $1 }' - This will take that list and if the second column says exactly deinstall, the first column (package name) will be printed.
dpkg --purge $() - This will purge anything that is produced as input. This should be a list of packages that were deinstalled.
What this does:
It destroys (purges) all files left over from a deinstalled package. This applies to more than just /etc/ but will have the biggest cleanup factor here.
You should try this command out and see the difference it makes. As a generic benchmark:
ls -lR /etc > ~/before
dpkg --purge $(dpkg --get-selections | awk '$2 == "deinstall" { print $1 }')
ls -lR /etc > ~/after
wc -l ~/before && wc -l ~/after
If you want to see more of a benchmark, 'ls -lR /{etc,var/lib*,usr}' - but results here will be a little more skewed. A word of warning - this is exactly like if you were to install the package again and then purge it. It can destroy configs that you wrote if you wrote them for that application. Use a little common sense in doing something like this.
Thanks to Scott Shields for getting me started on wanting to do this.
Robert Wall also had the following idea.
aptitude --purge-unused purge ~c