Results 1 to 9 of 9

Thread: Howto: Create a list of all "installed" packages by date

Threaded View

  1. #1
    Join Date
    Mar 2006

    Smile Howto: Create a list of all "installed" packages by date

    NB: This part grep " \ install\ ", seems to be not working on my 12.04 install. You can replace with grep -w install while I investigate.

    I've seen a request for this several times on the forum and never really seen a concrete answer: how to list all the packages that have been installed since the OS was installed, by date. Yes, you can get a list by using "dpkg -l", but this doesn't give the whole story.

    The answer comes from the dpkg.log files in /var/log. There is the current log (dpkg.log), the previous log (dpkg.log.1) and then the archived logs (dpkg.log.2.gz -> ).

    The simple command to grab from the current log is:

    cat /var/log/dpkg.log | grep " \ install\ "
    The previous log:

    cat /var/log/dpkg.log.1 | grep " \ install\ "
    And archived logs:

    zcat /var/log/dpkg.log.2.gz | grep " \ install\ "
    To get the full list of packages installed I wrote a simple bash script. The script I called, put it in my home directory and ensured it was executable:

    chmod a+x $HOME/
    Here is 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
    Running it:
    creates a file in my home directory called pkginstalls.txt that I can then use to examine what was installed and when. Unfortunately it doesn't show meta-packages such as "xubuntu-restricted-extras" but if you are aware of some of the contents of meta-packages you should be able to track down where it happened.

    Delete or rename the pkginstalls.txt file before you run the script again.

    If you have been religiously installing via the command line, and you have enabled a long enough history file, you can get similar information (no date, and excluding initial installation) by typing:
     history | grep "apt-get install"
    This script is benign and doesn't affect any part of your system. To remove just delete the script.


    There is also more detailed installation information in /var/log/apt/ in the history.log and history.log.X.gz files and term.log and term.log.X.gz files
    Last edited by Jose Catre-Vandis; May 28th, 2012 at 06:49 PM.
    No longer participating......

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts