Is there a way to identify packages, perhaps by analysing files in a package and when they were last accessed, to identify when a package was last used?
Are there perhaps existing solutions for this, maybe even part of apt already that would show me this?
It would be helpful to identify packages and applications that are rarely, or no longer, used and which could potentially be deleted from the system to free up space. (At least that's what I am trying to accomplish).
Though I am sure there is a way to do this with just Bash scripting, I wrote a little script (which calls shell commands anyway to execute
dpkg
) in Ruby.What it does is:
dpkg -S /usr/bin/*
to get a list of all the packages that each of the files in/usr/bin
belong to.atime
) of each file in the package and sorts the list by the timeA better approach would probably be to go through each package, list all the files in the package, and find the last access time for each file, and so find the maximum access time for each package. (Which sounds like it should be doable with some single line Bash script).
Perhaps someone could be so kind as to provide a Bash-only version that does the same thing?
You can test it, as I did, by running some binary from some package and seeing that, when you run the script again, the timestamp next to the package changes and moves it to the bottom of the list.
This kind of works for me, though I would still be a bit hesitant to delete some of the packages, even though their usage seems like it might date back to when I installed the system on my machine.