Once in a while, as a Linux user, you may want to conduct an audit of the status of various installed packages on your Linux machine. The main purpose is to keep track of the packages installed and those that were removed at a certain point in time. In this article, we are going to delve into checking the transaction status of installed packages in Fedora 27 using the DNF history command. This will give you a glimpse of the history of packages that were manually installed and removed in chronological order.
Retrieving a list of manually installed packages using dnf
To retrieve a list of manually installed packages by the user , we run the command below
dnf history userinstalled
Sample Output
Packages installed by user httpd gnome-tweak-tool nodejs
Retrieving a list of all transactions
To display a list of all previous transactions carried out in the system, run the command below
dnf history list all
Sample Output
ID | Command line | Date a | Action | Altere ------------------------------------------------------------------------------- 3 | install gnome-tweak-tool | 2018-02-11 22:50 | Install | 2 2 | remove httpd | 2018-02-11 22:42 | Erase | 4 1 | install nodejs | 2018-02-11 22:33 | Install | 4
Listing changes of a particular transaction
To list changes of a particular transaction append the ID of the transaction at the end of the command. For instance, If we want to check the changes to ID 1 in the above example which is installation of nodejs we run the command as shown
dnf history list 1
Sample output
ID | Command line | Date a | Action | Altere ------------------------------------------------------------------------------- 1 | install nodejs | 2018-02-11 22:33 | Install | 4
Retrieving information about packages of a certain transaction
To display information about packages of a certain transaction, we run the command as shown
dnf history info 1
Sample output
Transaction ID : 1 Begin time : Sun Feb 11 22:33:32 2018 Begin rpmdb : 1403:93d810e4d47f231ae56e62f96163e3d6b01ba7aa End time : 22:33:52 2018 (20 seconds) End rpmdb : 1407:77a7d6293b725b707e548ed7015a05eaf503d49c User : jamie Return-Code : Success Command Line : install nodejs Transaction performed with: Installed dnf-0.6.1-1.fc21.noarch (unknown) Installed rpm-4.12.0.1-3.fc21.x86_64 (unknown) Packages Altered: Install http-parser-2.0-7.20121128gitcd01361.fc21.x86_64 @fedora Install libuv-1:0.10.34-1.fc21.x86_64 @updates Install nodejs-0.10.36-3.fc21.x86_64 @updates Install v8-1:3.14.5.10-18.fc21.x86_64 @updates
How to undo a complete transaction
If you want to roll back a transaction, say the uninstallation or installation of a package, use the undo option followed by the transaction ID in the command as a shown. First, we'll list the transaction history.
dnf history list all
Sample Output
ID | Command line | Date a | Action | Altere ------------------------------------------------------------------------------- 3 | install gnome-tweak-tool | 2018-02-11 22:50 | Install | 2 2 | remove httpd | 2018-02-11 22:42 | Erase | 4 1 | install nodejs | 2018-02-11 22:33 | Install | 4
Let's roll back the uninstallation of httpd web server
dnf history undo 2
The above will reinstall httpd
Sample Output
[root@localhost ~]# dnf history undo 2 Undoing transaction 2, from Sun Feb 11 22:42:55 2018 Erase gnome-user-share-3.14.0-2.fc21.x86_64 (unknown) Erase httpd-2.4.16-1.fc21.x86_64 (unknown) Erase mod_dnssd-0.6-12.fc21.x86_64 (unknown) Erase php-5.6.15-1.fc21.x86_64 (unknown) ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: gnome-user-share x86_64 3.14.0-2.fc21 fedora 135 k httpd x86_64 2.4.16-1.fc21 updates 1.2 M mod_dnssd x86_64 0.6-12.fc21 fedora 27 k php x86_64 5.6.15-1.fc21 updates 2.6 M Transaction Summary ================================================================================ Install 4 Packages Total download size: 4.0 M Installed size: 13 M Is this ok [y/N]: Thank you for reading this post. If you have any questions regarding the usage of DNF history command, do not hesitate to contact us.