Debian has introduced functionality to the apt command which enables it to make changes to the system based on the history of changes apt has made. These enhancements are available in apt version 3.2 which is what this post is using in the examples below:
Whilst this is a debian testing installation which the following is using, over time the apt enhancements will doubtless be included in the apt packages that are used by the numerous debian derivatives.
Here's a brief table to show the history commands that I know of:
Running
The history list shows the commands that apt used in past installations of particular packages, past removal and purging of a package, past instances of each upgrade etc., all dated.
To inspect the details of any of those past invocations of apt, one uses the ID number with the history-info option. For example, to see what transaction 19 (autoremove) involved, one can run the following:
The output shows what the apt command removed.
The command:
The command:
The command:
In each case of its use, apt resolves dependencies.
Previous to these commands, a user was able to check on history by reference to the /var/log/apt/history.log files and work a bit laboriously if they wished to reverse or manage already executed apt commands.
One might consider the implications the apt history functions may have for other rollback methods such as those used in filesystems like btrfs where snapshots can be used to reverse installations. There may be implications for apps like timeshift and the cloning apps. For example, one might consider a history rollback facility sufficient to satisfy their needs for recovery. However, the apt history commands work at the level of the filesystem over which apt has purview, which is packages. They don't work at the level of a whole system "recollection" which snapshotting and cloning does where everything is captured including configurations and user's modifications. The economy of apt though may be attractive. For those running lesser versions of apt at the moment, I guess it's something to look forward to in a future upgrade
.
The current man page for apt on this machine's latest upgrade this morning hasn't as yet included the history commands.
Code:
[~]$ apt list apt
apt/testing,now 3.2.0 amd64 [installed]
Whilst this is a debian testing installation which the following is using, over time the apt enhancements will doubtless be included in the apt packages that are used by the numerous debian derivatives.
Here's a brief table to show the history commands that I know of:
Code:
History command Function
=============== ========
apt history-list view history, where an ID is assigned to each operation
apt history-info <ID> history of operation with the specified ID
apt history-undo <ID> reverse the operation with the specified ID
apt history-redo <ID> reverse a "history-undo" operation
apt history-rollback <ID> undoes all operations that happened after the specified ID
Running
apt history-list, to show the past transactions apt executed, has output such as the following, snipped for brevity:
Code:
[~]$ apt history-list
ID Command line Date and Time Action Changes
0 install extrepo 2025-04-07 20:22:53 Install 3
1 upgrade 2025-04-07 20:48:18 I,U 183
2 autoremove 2025-04-07 20:54:35 Remove 24
3 upgrade gstreamer1.0-... 2025-04-07 21:03:06 I,U,R 9
4 upgrade qutebrowser 2025-04-07 21:03:55 U,R 2
5 install agrep 2025-04-13 16:20:02 Install 1
6 upgrade 2025-04-14 21:12:43 I,U 177
7 install finger efinge... 2025-04-16 08:22:03 Install 3
8 remove finger efingerd 2025-04-16 13:13:15 Remove 2
9 purge finger efingerd 2025-04-16 13:13:32 Purge 1
10 install librewolf -y 2025-04-17 15:50:40 Install 1
11 upgrade 2025-04-25 08:29:08 I,U 107
12 install cpuinfo 2025-04-27 14:13:48 Install 1
13 install flex 2025-04-28 13:18:41 Install 3
14 install libear 2025-04-28 13:20:28 Install 7
15 install texinfo 2025-04-28 13:22:08 Install 4
16 install stress 2025-05-02 20:05:41 Install 1
17 upgrade 2025-05-04 13:38:27 I,U 191
18 upgrade 2025-05-08 21:26:01 I,U 61
19 autoremove 2025-05-09 10:46:24 Remove 27
20 install dysk 2025-05-11 11:47:44 Install 1
<snip>
To inspect the details of any of those past invocations of apt, one uses the ID number with the history-info option. For example, to see what transaction 19 (autoremove) involved, one can run the following:
Code:
[~]$ apt history-info 19
Transaction ID: 19
Start time: 2025-05-09 10:46:24
End time: 2025-05-09 10:46:32
Requested by:
Command line: apt autoremove
Packages changed:
Remove libabsl20230802:amd64 (20230802.1-4)
Remove libcairomm-1.16-1:amd64 (1.18.0-2)
Remove libdnnl3:amd64 (3.5.3-5)
Remove libglibmm-2.68-1t64:amd64 (2.84.0-1)
Remove libgtkmm-4.0-0:amd64 (4.18.0-1)
Remove libident0:amd64 (0.32-4+b2)
Remove libopenh264-7:amd64 (2.5.0+dfsg-1)
Remove libpangomm-2.48-1t64:amd64 (2.56.1-1)
Remove libpulse-mainloop-glib0:amd64 (17.0+dfsg1-2+b1)
Remove libqt5qmlworkerscript5:amd64 (5.15.15+dfsg-3)
Remove libqt5test5t64:amd64 (5.15.15+dfsg-5)
Remove libqt5webengine-data:amd64 (5.15.18+dfsg-2)
Remove libqt5webengine5:amd64 (5.15.18+dfsg-2+b1)
Remove libqt5webenginecore5:amd64 (5.15.18+dfsg-2+b1)
Remove libsigc++-3.0-0:amd64 (3.6.0-2+b1)
Remove libxnnpack0:amd64 (0.0~git20240821.87ee0b4-3)
Remove linux-headers-6.12.20-amd64:amd64 (6.12.20-1)
Remove linux-headers-6.12.20-common:amd64 (6.12.20-1)
Remove linux-headers-6.12.21-amd64:amd64 (6.12.21-1)
Remove linux-headers-6.12.21-common:amd64 (6.12.21-1)
Remove linux-image-6.12.20-amd64:amd64 (6.12.20-1)
Remove linux-image-6.12.21-amd64:amd64 (6.12.21-1)
Remove linux-kbuild-6.12.20:amd64 (6.12.20-1)
Remove linux-kbuild-6.12.21:amd64 (6.12.21-1)
Remove pavucontrol:amd64 (6.1-1)
Remove qml-module-qtquick2:amd64 (5.15.15+dfsg-3)
Remove qml-module-qtwebengine:amd64 (5.15.18+dfsg-2+b1)
The command:
apt history-undo 19, would reverse that command and reinstall the packages which were removed, and the apt solver, the mechanism for satisfying dependencies, would resolve all of those dependencies. I'm not running that because I don't want that to occur on this machine.The command:
apt history-redo 19, would reverse an undo such as the above command:apt history-undo 19, which in this case would again remove the packages as executed by apt with the autoremove option. That's a sort of "failsafe" command if a user executes a reversal, but then needs to reverse the reversal, that is, undo what they have done. It's not uncommon for a user to perform an action and then want it reversed, so this command which does that is very welcome.The command:
apt history-rollback <ID> undoes all operations that happened after a specified ID.In each case of its use, apt resolves dependencies.
Previous to these commands, a user was able to check on history by reference to the /var/log/apt/history.log files and work a bit laboriously if they wished to reverse or manage already executed apt commands.
One might consider the implications the apt history functions may have for other rollback methods such as those used in filesystems like btrfs where snapshots can be used to reverse installations. There may be implications for apps like timeshift and the cloning apps. For example, one might consider a history rollback facility sufficient to satisfy their needs for recovery. However, the apt history commands work at the level of the filesystem over which apt has purview, which is packages. They don't work at the level of a whole system "recollection" which snapshotting and cloning does where everything is captured including configurations and user's modifications. The economy of apt though may be attractive. For those running lesser versions of apt at the moment, I guess it's something to look forward to in a future upgrade
The current man page for apt on this machine's latest upgrade this morning hasn't as yet included the history commands.
Last edited:

