[CentOS] question on unused directories in /usr/lib and /usr/lib64

Wed Feb 15 22:05:49 UTC 2012
Lamar Owen <lowen at pari.edu>

On Wednesday, February 15, 2012 04:00:45 PM Craig Thompson wrote:
> Hardly kidding.  But then again, this is early April isn't it?  Oh, wait...
> 
> To "cleanly uninstall unused software," one would need a list of what software is ON the system which is unused.  

And one would need to define 'unused.'

The Windows Add/Remove Control Panel widget has an indicator of 'last usage' and it might be possible to emulate that to a degree by looking at the last accessed time for a library... hmmm, something like:

find /usr/lib64 ! -used +1 -exec rpm -qf \{\} \; |sort|uniq

might do *part* of what you want, at least for /usr/lib64.  I say *part* simply because this finds all files that have not been used more than 1 day after their status last changed and lists the package containing that file, sorts the output, and strips out all nonunique lines, but it is very possible that a package could have many, but not all, of its files 'used' and wind up on this list because of even just one unused file.... and what you want is to find each package where *none* of its files have been used since their status last changed (that is, since that package was last installed/modified).

But you'd want to actually *use* all of the programs you expect to be used before acting on that list.... and you'd want to take the packages on that list and feed them to 'rpm -ql' for each package, and see if *any* file in that package had been 'used' (in the 'find' sense of the word).  

Sounds like a 'yum remove-unused' plugin or 'yum-cleanup-unused' utility or an enhancement to 'package-cleanup' from the yum-utils package, really, since the yum API has all the hooks necessary to do this from python.  Python is guaranteed to be available on any EL system with a functional yum, and is much more powerful than shell for this sort of thing, so it would be a good fit, IMO.