Wednesday, November 24, 2010

Get a List of Installed Software in Chronological Order

There is a single log file that records all the apt activities, such as installs or upgrades, for the various package managers (dpkg, apt-get, synaptic, aptitude). It can be found here : /var/log/dpkg.log.
If you want to have a more comprehensive history of the installed packages, you can use:
cat /var/log/dpkg.log* | grep "\ install\ " | sort
The result is a chronological list of package installation events. (Note that if a package was installed and subsequently removed, it will still be on the list.)

It turns out that there used to be an apt-history package, but the creator gave it up -due to the fact that dpkg now does logging- in favor of a small script solution: http://redclay.altervista.org/wiki/doku.php?id=projects:old-projects .
Below is the bash function from that web site.

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
}


The code should be added to /root/.bashrc.
To run apt-history, you need to become root. Entering apt-history with no parameter will simply dump the change log file. To select what activities you want to see, you can enter one of install, upgrade, remove, rollback as a single parameter to apt-history.

Another way to quickly extract informations from apt logs (term.log) is apt-log .
Some examples that would help understanding the common usage of apt-log : http://mavior.eu/apt-log/examples/

Edit : another way to list your installed packages is http://man.cx/apt-show-versions

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.