Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I list installed packages by installation date? I installed a lot of stuff to compile a certain piece of code, and I want to get a list of the required packages, which are the ones I installed in the last few days.

I need to do that on debian/ubuntu, but answers for other distributions would be nice as well.

share|improve this question
See also How to get the history of apt-get install. – Mikel May 4 '11 at 7:49
I was googling for "apt release date" with no luck, maybe this comment will help future googlers. – ThorSummoner Nov 25 '14 at 18:43
up vote 37 down vote accepted

RPM-based distributions like Red Hat are easy:

rpm -qa --last

On Debian and other dpkg-based distributions, your specific problem is easy too:

grep install /var/log/dpkg.log

Unless the log file has been rotated, in which case you should try:

grep install /var/log/dpkg.log /var/log/dpkg.log.1

In general, dpkg and apt don't seem to track the installation date, going by the lack of any such field in the dpkg-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:

ls -t /var/lib/dpkg/info/*.list | sed -e 's/\.list$//' | head -n 50

To answer your question about selections, here's a first pass.

build list of packages by dates

$ find /var/lib/dpkg/info -name "*.list" -exec stat -c $'%n\t%y' {} \; | \
    sed -e 's,/var/lib/dpkg/info/,,' -e 's,\.list\t,\t,' | \
    sort > ~/dpkglist.dates

build list of installed packages

$ dpkg --get-selections | sed -ne '/\tinstall$/{s/[[:space:]].*//;p}' | \
    sort > ~/dpkglist.selections

join the 2 lists

$ join -1 1 -2 1 -t $'\t' ~/dpkglist.selections ~/dpkglist.dates \
    > ~/dpkglist.selectiondates

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> or head -n <lines>, and change the output format as you like, e.g.

$ find /var/lib/dpkg/info -name "*.list" -mtime -4 | \
    sed -e 's,/var/lib/dpkg/info/,,' -e 's,\.list$,,' | \
    sort > ~/dpkglist.recent

$ join -1 1 -2 1 -t $'\t' ~/dpkglist.selections ~/dpkglist.recent \
    > ~/dpkglist.recentselections

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 by dpkg --get-selections and make the find command more efficient.

share|improve this answer
I usually like apt-get more than rpm, but now debian gets -1 for not saving the installation date in the database. The debian trick includes all the installed packages, not just the selected packages, but it's a good start. – Elazar Leibovich May 4 '11 at 6:53

Mikel has shown how to do this at the dpkg level. In particular, /var/lig/dpkg/info/$packagename.list is created when the package is installed (and not modified afterwards).

If you used the APT tools (which you presumably did since you're concerned about automatically vs manually installed packages), there's a history in /var/log/apt/history.log. As long as it hasn't rotated away, it keeps track of all APT installations, upgrades and removals, with an annotation for packages marked as automatically installed. This is a fairly recent feature, introduced in APT 0.7.26, so in Debian it appeared in squeeze. In Ubuntu, 10.04 has history.log but the automatically-installed annotation is not present until 10.10.

share|improve this answer
Interesting. What version of Debian did that appear in? – Mikel May 4 '11 at 7:43
@Mikel: squeeze. – Faheem Mitha May 4 '11 at 8:09
@Mikel: Looking at the changelog, this arrived in 0.7.26~exp1, dated 18 Feb 2010. – Faheem Mitha May 4 '11 at 8:23

rough, but works :

for fillo in `ls -tr /var/lib/dpkg/info/*.list` ; 
    do basename ${fillo} | sed 's/.list$//g' ; 
done  > forens.txt

ls -ltr /var/lib/dpkg/info/*.list > forentime.txt

for lint in `cat forens.txt` ; do 
    echo -n "[ ${lint} Installed ] : " ; 
    echo -n "`grep /${lint}.list forentime.txt | awk '{ print $6, $7, $8 }'` : " ; 
    ( ( grep -A3 " ${lint}$" /var/lib/apt/extended_states | grep '^Auto' > /dev/null ) && echo "Auto" ) || echo "Manual" ; 
done > pkgdatetime.txt
share|improve this answer
Boo, hiss for parsing output from ls. See mywiki.wooledge.org/ParsingLs for notes on why this is dangerous / inherently buggy -- the safer option is to use either find -printf or stat --format to generate a stream that can be unambiguously parsed. – Charles Duffy Apr 10 '15 at 17:17

The /var/log/apt/history.log file has an awkward format IMHO.

Start-Date: {date} {time} Commandline: {command} {options ...} Install: {package (version)}, ..., {package (version)}, ... End-Date: {date} {time}

I would have preferred a more log-file formatted record


or some XML showing not only a {package} but any {dependencies}.

As currently implemented, you can discover the information you seek but it requires some forensic processing to extract the details.

share|improve this answer

This works for me on a debian system, i'm guessing the file format has changed since 2011 . This system is pretty fresh so i wouldn't expect this to work on an older system, although that might just require unzipping the logs and using a glob to refer to all of them.

grep 'install ' /var/log/dpkg.log.1 | cut -f4 -d' '

/var/log/dpkg.log has a date and time in it which you will see if you don't pipe it through cut. Note the trailing space with install in the grep part, this is because upgrades can trigger installs but if I understood correctly you wanted to know what was installed by users.

share|improve this answer

Noting this because you mention that other distribution answers are welcome. rpm has a large set of output format tags, one of which is INSTALLTIME. (Using wget as an example)

rpm -qi wget --qf "%{NAME},%{INSTALLTIME}\n" | tail -n 1

This can be formatted in a few ways. I use it in this way:

rpm -qi wget --qf "%{NAME},%{INSTALLTIME:date}\n" | tail -n 1
wget,Thu 28 Jan 2016 03:49:16 PM EST

These two pages have a ton of great info on solving RPM metadata issues:



Sorting this information would give you a working solution for your issue.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.