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:
The previous log:
cat /var/log/dpkg.log | grep " \ install\ "
And archived logs:
cat /var/log/dpkg.log.1 | grep " \ install\ "
To get the full list of packages installed I wrote a simple bash script. The script I called pkginstalls.sh, put it in my home directory and ensured it was executable:
zcat /var/log/dpkg.log.2.gz | grep " \ install\ "
Here is the script:
chmod a+x $HOME/pkginstalls.sh
#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
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:
This script is benign and doesn't affect any part of your system. To remove just delete the script.
history | grep "apt-get install"
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