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).

  • 3
    First question ever asked !
    – Liso
    Commented Jun 26, 2020 at 3:55

8 Answers 8


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
    Commented Sep 13, 2012 at 20:50

By default, aptitude writes to a log file /var/log/aptitude. It produces output like this:


Aptitude 0.8.12: log report
Sun, Oct  1 2021 23:59:59 +1300

  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.
31.3 MB of disk space will be used
[UPGRADE] libc-dev-bin:amd64 2.31-0ubuntu9 -> 2.31-0ubuntu9.2
[UPGRADE] libc6:amd64 2.31-0ubuntu9 -> 2.31-0ubuntu9.2
[UPGRADE] libc6:i386 2.31-0ubuntu9 -> 2.31-0ubuntu9.2
[UPGRADE] libc6-dbg:amd64 2.31-0ubuntu9 -> 2.31-0ubuntu9.2
[UPGRADE] libc6-dev:amd64 2.31-0ubuntu9 -> 2.31-0ubuntu9.2
[UPGRADE] libc6-i386:amd64 2.31-0ubuntu9 -> 2.31-0ubuntu9.2

Log complete.

This shows the exact date and packages that aptitude installed. To configure this (in /etc/apt/apt.conf or in a separate file in /etc/apt/apt.conf.d/), follow the Configuration file reference in aptitude manual (also available from "Help > User's Manual" in the menu):



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.
  • 2
    Please post the link and how to implement it. Just referring to some manual text is not very helpful.
    – not2qubit
    Commented Apr 26, 2018 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
    Commented Jul 21, 2013 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
    Commented Jul 21, 2013 at 1:27
  • 2
    or just "grep install /var/log/dpkg.log*" ? Commented Oct 25, 2017 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
    Commented Dec 18, 2017 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
    Commented Feb 16, 2017 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
    Commented Feb 17, 2017 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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .