Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

share|improve this question

migrated from stackoverflow.com Oct 28 '11 at 13:44

This question came from our site for professional and enthusiast programmers.

    
+1 good question. See comments of stackoverflow.com/questions/487737. 4 down, 11 to go (1 per day) –  VonC Feb 12 '09 at 5:15

8 Answers 8

up vote 21 down vote accepted

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.

share|improve this answer
    
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 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.

share|improve this answer

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?

share|improve this answer

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

cd /var/log

Search for all dpkg.log, dpkg.log.1 by for example executing:

ls | grep 'dpkg.log'    

and type:

cat /var/log/dpkg.log | cat /var/log/dpkg.log.1 | grep " install "

(if you have more dpkg.log.x append them as well) As a result you will get nice list of all installed packages with exact date and time.

share|improve this answer
1  
The cd command is not necessary if you use the full path in the catcommand... –  papukaija Jul 21 '13 at 0:15
    
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. –  user2041318 Jul 21 '13 at 1:27

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.

share|improve this answer

You can always try this apt-log.

share|improve this answer
4  
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. –  Mitch Aug 21 '12 at 7:43

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

share|improve this answer
  • 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> 0.7.0.55225-1 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

share|improve this answer

Your Answer

 
discard

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.