1

I want to get the list of installed packages to perform a fresh installation.

There are many ways of getting these e.g. https://wiki.debian.org/ListInstalledPackages but all produce impractically long lists including dependencies and system packages.

How can I get a list of user installed packages?

1

All actions performed by apt are logged in /var/log/apt/ but this too has excessive detail and many logs are compressed.

The following script produces a list of actions and the dates on which they were performed.

#!/bin/bash
#Print apt-get history
# 2017-08-06
for logf in $(ls /var/log/apt/history.log.*.gz | sort -rV) ; do zcat $logf | grep -E "Start-Date:|Commandline:" ; done
# Include most recent
grep -E "Start-Date:|Commandline:" /var/log/apt/history.log

This produces a more manageable list which is easily edited to remove the many "apt upgrade' etc and leave a simple list - the following is an extract:-

Commandline: apt upgrade
Start-Date: 2018-10-24  17:55:57
Commandline: apt install sysbench
Start-Date: 2018-10-29  16:09:33
Commandline: apt-get install --reinstall ssmtp
Start-Date: 2018-10-31  10:23:12
Commandline: apt upgrade
Start-Date: 2018-11-05  17:43:45
Commandline: apt upgrade
Start-Date: 2018-11-05  19:06:56
Commandline: apt purge phpmyadmin
Start-Date: 2018-11-17  10:16:44
Commandline: apt dist-upgrade
Start-Date: 2018-11-17  14:33:07
Commandline: packagekit role='remove-packages'

There are some limitations;

  1. only the last 12 months are shown (because the logs are rotated monthly and only the 12 most recent are kept) but this can be extended by editing /etc/logrotate.d/apt
  2. The Recommended Software program does not list packages added/removed - just a cryptic packagekit role='remove-packages' although the full log does show what was done.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.