How can I list installed packages by installation date?
I need to do this on debian/ubuntu. Answers for other distributions would be nice as well.
I installed a lot of stuff to compile a certain piece of code, and I want to get a list of the packages that I had to install.
Best Answer
RPM-based distributions like Red Hat are easy:
On Debian and other dpkg-based distributions, your specific problem is easy too:
Unless the log file has been rotated, in which case you should try:
In general,
dpkg
andapt
don't seem to track the installation date, going by the lack of any such field in thedpkg-query
man page.And eventually old
/var/log/dpkg.log.*
files will be deleted by log rotation, so that way isn't guaranteed to give you the entire history of your system.One suggestion that appears a few times (e.g. this thread) is to look at the
/var/lib/dpkg/info
directory. The files there suggest you might try something like:To answer your question about selections, here's a first pass.
build list of packages by dates
build list of installed packages
join the 2 lists
For some reason it's not printing very many differences for me, so there might be a bug or an invalid assumption about what
--get-selections
means.You can obviously limit the packages either by using
find . -mtime -<days>
orhead -n <lines>
, and change the output format as you like, e.g.to list only the selections that were installed (changed?) in the past 4 days.
You could probably also remove the
sort
commands after verifying the sort order used bydpkg --get-selections
and make thefind
command more efficient.