History management in APT

I previously wrote an article (Viewing APT History) about a function I wrote to be able to view APT package manager history. As of today that function has become obsolete with changes in Update 25.10 which introduced a history function within the APT package manager, and futher enhancements in Ubuntu 26.04 make this a formidable step forward.

APT now provides an interface for viewing and manipulating it's command history. These changes introduces five new sub-commands

ubuntu26$ apt --help
...
  history-list - show list of history
  history-info - show info on specific transactions
  history-redo - redo transactions
  history-undo - undo transactions
  history-rollback - rollback transactions
...

These sub-commands are designed to parse APT's log files natively, without requiring external scripts or third-party tools. In practice, this means users will be able to check when a package was installed, upgraded, or removed, along with the corresponding transaction details.

Below are some examples of this new functionality.

history-list — Show list of history

ubuntu26$ apt history-list
ID   Command line             Date and Time          Action    Changes

0    install hp2xx            2026-04-23  17:00:00   Install   1
1    upgrade                  2026-04-23  18:15:00   Upgrade   11
2    build-dep .              2026-04-24  18:30:00   Install   4

history-info — Show info on specific transactions

ubuntu26$ apt history-info 0
Transaction ID: 0
Start time: 2026-04-23  17:00:00
End time: 2026-04-23  17:00:05
Requested by: church1e (1000)
Command line: apt install hp2xx
Packages changed:
    Install hp2xx:amd64 (3.4.4-12build4)

history-undo — Undo transactions

ubuntu26$ sudo apt history-undo 0
REMOVING:
  hp2xx

Summary:
  Upgrading: 0, Installing: 0, Removing: 1, Not Upgrading: 0
  Freed space: 591 kB

Continue? [Y/n]

history-redo — Redo transactions

ubuntu26$ sudo apt history-redo 0
hp2xx is already the newest version (3.4.4-12build4).
Summary:
  Upgrading: 0, Installing: 0, Removing: 0, Not Upgrading: 0

history-rollback — Rollback transactions

ubuntu26$ sudo apt history-rollback 1
REMOVING:
libtext-unidecode-perl  tex-common  texinfo  texinfo-lib

Summary:
  Upgrading: 0, Installing: 0, Removing: 4, Not Upgrading: 0
  Freed space: 8119 kB

To summerise, we'll no longer need to rely on commands like dpkg -l | grep <pkg-name> to find out if a package is already installed or sift through endless dpkg (/var/log/dpkg.log*) and apt (/var/log/apt/history.log.*.gz) log files to figure out when a change happened.