views:

778

answers:

5

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 was installing a bunch of packages to try something new, and 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).

+4  A: 

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.

mok0
+2  A: 

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
        install)
              cat /var/log/dpkg.log | grep 'install '
              ;;
        upgrade|remove)
              cat /var/log/dpkg.log | grep $1
              ;;
        rollback)
              cat /var/log/dpkg.log | grep upgrade | \
                  grep "$2" -A10000000 | \
                  grep "$3" -B10000000 | \
                  awk '{print $4"="$5}'
              ;;
        *)
              cat /var/log/dpkg.log
              ;;
      esac
}

Source

EDIT

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

furtelwart
A: 

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.

+2  A: 

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

Aptitude 0.4.11.11: 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 0.7.20.1 -> 0.7.20.2
[UPGRADE] apt-utils 0.7.20.1 -> 0.7.20.2
[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 (obviously :) ) the exact date and packages that aptitude installed. To configure this, follow the aptitude reference;

Option:Aptitude::Log

Default:/var/log/aptitude

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.

jeremiah
A: 

Try this http://mavior.eu/apt-log