Does anyone know if there's an easy way to find a list of packages installed, sorted by date, when using aptitude (or apt-get)?

I installed a bunch of packages to try something new, but it didn't work out. I'd like to remove all of these packages, to get back some disk space.

I've tried just looking at the list of .deb files downloaded, but that seems like a rather backwards way of doing it (although it did work).

  • First question ever asked ! – Liso Jun 26 '20 at 3:55
  • @Liso: But why does it have an ID of 73180? I would have expected an ID much closer to 1. – Peter Mortensen Feb 4 at 14:43

Unfortunately, dpkg (the package handler aptitude works on top of) does not specifically save the install date of packages, although there's thoughts of adding it. However, the install date can be found by looking at the date stamp of files written to the directory /var/lib/dpkg/info.

  • 4
    If you use this approach, be sure to only check the timestamps on the *.list files as the other files are stamped with the package date. – Dave Sep 13 '12 at 20:50

I have configured aptitude to write to a log (/var/log/aptitude). It produces output like this;

Aptitude log report
Mon, Feb  9 2009 13:21:28 +0100

IMPORTANT: this log only lists intended actions; actions which fail due to
dpkg problems may not be completed.

Will install 6 packages, and remove 0 packages.
4096B of disk space will be used
[UPGRADE] apt ->
[UPGRADE] apt-utils ->
[UPGRADE] base-passwd 3.5.19 -> 3.5.20
[UPGRADE] libgnutls26 2.4.2-5 -> 2.4.2-6
[UPGRADE] libpq5 8.3.5-1 -> 8.3.6-1
[UPGRADE] ucf 3.0015 -> 3.0016

Log complete.

This shows the exact date and packages that aptitude installed. To configure this, follow the aptitude reference;



Description: If this is set to a nonempty string, aptitude will log the package
installations, removals, and upgrades that it performs. If the value of
Aptitude::Log begins with a pipe character (ie, ``|''), the remainder of its
value is used as the name of a command into which the log will be piped: for
instance, |mail -s 'Aptitude install run' root will cause the log to be emailed
to root. To log to multiple files or commands, you may set this option to a list
of log targets.

You will find a link to the aptitude reference in the aptitude man page.

  • 2
    Please post the link and how to implement it. Just referring to some manual text is not very helpful. – not2qubit Apr 26 '18 at 13:46

There is a simple way to see all packages installation date. Just execute:

grep " install" /var/log/dpkg.log*

As a result you will get a list of all installed packages with exact date and time.

Thanks for comments which lead me to that solution.

  • 2
    The cd command is not necessary if you use the full path in the catcommand... – papukaija Jul 21 '13 at 0:15
  • 1
    The purpose of cd command was to ls inside this directory to check available dpkg.log files. But better solution will be running ls /var/log | grep 'dpkg.log' in order to list log files. Sorry for the mess. – jmarceli Jul 21 '13 at 1:27
  • 2
    or just "grep install /var/log/dpkg.log*" ? – Marc Van Daele Oct 25 '17 at 10:19
  • 1
    Huh, I didn't know cat | cat was a thing you could do. But why not cat both files in one command? (Or even better: just do what @MarcVanDaele says.) – mwfearnley Dec 18 '17 at 10:58

I found this one here on the web. It creates a history of dpkg out of the dpkg log file.

It looks very simple.

function apt-history(){
      case "$1" in
              cat /var/log/dpkg.log | grep 'install '
              cat /var/log/dpkg.log | grep $1
              cat /var/log/dpkg.log | grep upgrade | \
                  grep "$2" -A10000000 | \
                  grep "$3" -B10000000 | \
                  awk '{print $4"="$5}'
              cat /var/log/dpkg.log



I tried this script on Ubuntu 8.10 Server and it works very well. Could you provide some information, how you solved your problem?

  • Use the dpkg logs

    locate dpkg.log | xargs cat {} | grep " install "
  • OR if you don't have locate

    find /var/log/ -name 'dpkg.log' | xargs cat {} | grep " install "
  • Use sort to ensure proper time based ordering

    locate dpkg.log | xargs cat {} | grep " install " | sort
  • Use tac (reverse cat)*, head e.g to get latest 4 entries

    locate dpkg.log | xargs cat {} | grep " install " | sort | tac | head -n4

e.g For the last command, I get:

2014-10-08 18:56:12 install xorg-server-source:all <none> 2:1.16.1-1
2014-10-08 18:49:34 install libelementary-data:all <none>
2014-10-08 18:46:57 install e17:i386 <none> 0.17.6-1
2014-10-08 18:46:56 install libedje-bin:i386 <none> 1.8.6-2.1+b1
  • 1
    Why would you use tac + head instead of tail? – Zanna Feb 16 '17 at 10:18
  • 1
    It's been a while, I've forgotten why - but it's possible there's an entirely good reason for it .. or maybe I had a blonde moment :D – a20 Feb 17 '17 at 9:25

You can also track down your previous actions by checking /var/log/apt/term.log, and older files term.log.1.gz etc.). It has timestamps and complete log from messages during install.


There is indeed an 'official' pkginstall.sh script that can do this. Follow the instructions in the official documentation. Briefly, download the script from the above link, make sure it is executable and then run with:


This will create pkginstalls.txt file in your home directory containing all the installed packages sorted by date.

BTW, this is the content of the script:

#creates text file with a list of all packages installed by date

#first append all info from archived logs

mycount=$(ls -l /var/log/dpkg.log.*.gz | wc -l)
nlogs=$(( $mycount + 1 ))

while [ $i -le $nlogs ]
if [ -e /var/log/dpkg.log.$i.gz ]; then
zcat /var/log/dpkg.log.$i.gz | grep "\ install\ " >> $HOME/pkgtmp.txt
i=$(( $i+1 ))


#next append all info from unarchived logs

nulogs=$(ls -l /var/log/dpkg.log.* | wc -l)
nulogs=$(( $nulogs - $nlogs + 1 ))
while [ $i -le $nulogs ]
if [ -e /var/log/dpkg.log.$i ]; then
cat /var/log/dpkg.log.$i | grep "\ install\ " >> $HOME/pkgtmp.txt
i=$(( $i+1 ))


#next append current log

cat /var/log/dpkg.log | grep "\ install\ " >> $HOME/pkgtmp.txt

#sort text file by date

sort -n $HOME/pkgtmp.txt > $HOME/pkginstalls.txt

rm $HOME/pkgtmp.txt

exit 0

[ANSWERING THE ACTUAL QUESTION], Yes, there is an EASY way to look up packages installed on a particular date, even if it was done inside of terminal using apt-get.

If you install the Synaptic Package Manager, which is freely installable from the Ubuntu Software Center, you need only open its FILE menu and choose the "History" option. There you will find an accounting of all added and removed application packages, organized by date, regardless of how they came to be installed or removed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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