Ubuntu – How to remove all updates installed after a specific date

aptpackage-managementsoftware-centerupdate-managerupdates

I have allowed the update manager to install a 200 Mib of updates, and I think that these update run my graphics driver into a problem. So, I need a way to remove the updates that have been installed since 30th of may 12 for example (or any other date). If I have to remove them manually (in the case of uninstalling them one by one), you are kindly requested to give me the instructions of how to do that.

Best Answer

There is an alternative, command line approach to getting installation history.

The package manager apt seems to log everything in /var/log/apt/history.log and /var/log/apt/term.log, including separating everything by datestamps. Both contain similar, usable information but term.log is both more verbose and doesn't explicitly indicate what initiated the operation.

History log

/var/log/apt/history.log stores a concise summary of each apt run. Here's a snippet of mine for a manual installation:

Start-Date: 2014-08-22  17:17:52
Commandline: apt-get install nautilus-dropbox
Install: nautilus-dropbox:amd64 (1.6.1-1), python-gpgme:amd64 (0.3-0ubuntu3, automatic)
End-Date: 2014-08-22  17:19:13

The Commandline: field indicates what triggered the run, and in the case of installations made by the update manager it should look something like:

Commandline: aptdaemon role='role-commit-packages' sender=':1.131'

...and there's your list of packages, sorted by date, method and action (install/upgrade/remove). Note that if you want to to pass these packages back to apt-get remove ...:

  • As mentioned, this completely removes packages rather than reverting them. The information in the logs could certainly be used to look at upgraded packages, though rolling them back is another matter.
  • You'll need to strip out the parentheses, their content and comma separator from the list via your preferred method of text manipulation (e.g. sed, vim etc.). So if I wanted to remove the packages in the snippet above I can use the line relatively directly:

    sudo apt-get remove nautilus-dropbox:amd64 python-gpgme:amd64
    

Terminal log

Generally /var/log/apt/term.log is less conveniently structured but, for the sake of completeness, you can get the same information. Terminal output is delimited by timestamps again, and package installations can be got from lines of the following form:

Selecting previously unselected package nautilus-dropbox.

The following is one way of printing a list of installed packages to the terminal for the entire log:

$ awk '/^Selecting/ {gsub(/\./,""); print $5}' /var/log/apt/term.log

This can be adapted or extended to get installations in a date range.