# ASSUMING your dpkg Logs go back to the initial machine install
###(May/Probablly NOT work across dist-upgrades)
apt-mark showauto >/tmp/auto.pkgs
Create a full dpkg timeline log
cp /dev/null /tmp/dpkg.full
for LOG in $(ls -rt /var/log/dpkg.log.[0-9].gz /var/log/dpkg.log.1[0-9].gz)
do
test -e $LOG && gunzip -c $LOG>> /tmp/dpkg.full
done
for LOG in $(ls -rt /var/log/dpkg.log /var/log/dpkg.log.[0-9] /var/log/dpkg.log.1[0-9])
do
test -e $LOG && cat $LOG >>/tmp/dpkg.full
done
Now Filer out the packages initially installed by the OS
awk -v initialinstall=1 '
/ install grub-pc / {initialinstall = 0; next;}
/ install / {if ( initialinstall == 0) print $4;}
' /tmp/dpkg.full | grep -vf /tmp/auto.pkgs >~/iInstalled.pkgs