Want to see what has recently been installed? Want to undo dnf update that just broke your X server? Then you've come to the right place!
In this brief how to I will be explaining the fundamentals of viewing & undoing yum/dnf updates on an RPM-based Linux distro.
What Is Yum? What is DNF? Link to heading
Yum (Yellowdog Updater, Modified) is the package manager for RPM based distros like CentOS & Fedora, it can be used to install, update and remove packages on the systems. The main benefit of yum over the standard RPM utilities is that it seeks out dependencies to reduce the risk of breaking your system. As of Fedora 22, DNF (Dandified Yum) has become the default package manager, replacing yum whilst retaining similar, but improved, functionality. The DNF command itself works incredibly similarly to Yum so moving from one command to the other is rather easy!
In this article I use the dnf command but you can replace dnf with yum if you're running an older version of CentOS/Fedora.
View History Link to heading
- View list of transactions
[stuart@asuka ~]$ sudo dnf history
ID | Command line | Date and time | Action(s) | Altered
-------------------------------------------------------------------------------
46 | install httraqt.x86_64 | 2016-10-17 15:16 | Install | 1
45 | install httrack.x86_64 | 2016-10-17 14:17 | Install | 1
44 | update spotify | 2016-09-26 12:05 | Update | 1
43 | install Downloads/SOFTWA | 2016-09-23 11:31 | Install | 1 EE
42 | install java-1.8.0-openj | 2016-09-23 11:28 | Install | 3
41 | update java | 2016-09-23 11:27 | Update | 2
40 | reinstall icedtea-web | 2016-09-23 11:08 | Reinstall | 1 EE
39 | remove jre-1.7.0_51 | 2016-09-23 11:07 | Erase | 1 EE
38 | reinstall icedtea-web.x8 | 2016-09-23 11:05 | Reinstall | 1 EE
37 | install icedtea-web.x86_ | 2016-09-23 11:02 | Install | 7 EE
36 | remove icedtea-web | 2016-09-16 11:46 | Erase | 7 <
35 | update spotify | 2016-08-17 12:58 | Update | 1 >
34 | install icedtea-web.x86_ | 2016-08-16 16:52 | Install | 7
The above command output has been stripped down to show a few parts of the history. As you can see, any transaction is logged, not just installs & updates.
View Details of Transaction Link to heading
- View details of transaction (using ID from previous command output)
[stuart@asuka ~]$ sudo dnf history info 45
Transaction ID : 45
Begin time : Mon Oct 17 14:17:46 2016
Begin rpmdb : 2307:e53988d93aa852086c981c3ba998e011cd8dc4d8
End time : 14:21:22 2016 (216 seconds)
End rpmdb : 2308:32a323e0478b458c74e9600ab5266f373badb04f
User : Stuart Franks <stuart>
Return-Code : Success
Command Line : install httrack.x86_64
Transaction performed with:
Installed dnf-1.1.10-1.fc23.noarch (unknown)
Installed rpm-4.13.0-0.rc1.13.fc23.x86_64 @updates
Packages Altered:
Install httrack-3.48.22-1.fc23.x86_64 @updates
As you can see, the only alteration was that the package httrack was installed into the system. More complex transactions will show the dependencies installed as well, see the below example for the installation of icedtea-web (a package for running Java web applications).
Transaction ID : 37
Begin time : Fri Sep 23 11:02:49 2016
Begin rpmdb : 2297:a73b3ab5c399514bd42d7c3c1841e4bb2f006c88
End time : 11:03:12 2016 (23 seconds)
End rpmdb : 2304:80d53902f883c9b5880eed00e9ec826a687f6edc
User : Stuart Franks <stuart>
Return-Code : Success
Command Line : install icedtea-web.x86_64
Transaction performed with:
Installed dnf-1.1.10-1.fc23.noarch (unknown)
Installed rpm-4.13.0-0.rc1.13.fc23.x86_64 @updates
Packages Altered:
Install hawtjni-runtime-1.10-5.fc23.noarch @fedora
Install icedtea-web-1.6.2-1.fc23.x86_64 @updates
Install jansi-1.11-9.fc23.noarch @fedora
Install jansi-native-1.5-9.fc23.x86_64 @fedora
Install jline-2.13-1.fc23.noarch @updates
Install rhino-1.7.7-2.fc23.noarch @fedora
Install tagsoup-1.2.1-10.fc23.noarch @fedora
Scriptlet output:
1 the primary link for libjavaplugin.so.x86_64 must be /usr/lib/mozilla/plugins/libjavaplugin.so
2 warning: %post(icedtea-web-1.6.2-1.fc23.x86_64) scriptlet failed, exit status 2
The above output shows that multiple packages were installed as well as detailing the warning/error messages from the RPM scriptlets.
Undo DNF Transaction Link to heading
- Undo dnf transaction (using ID from the first command output)
[stuart@asuka ~]$ sudo dnf history undo 42
Last metadata expiration check: 2:12:00 ago on Tue Oct 18 11:40:58 2016.
Undoing transaction 42, from Fri Sep 23 11:28:28 2016
Install giflib-4.1.6-14.fc23.i686 @fedora
Install java-1.8.0-openjdk-1:1.8.0.102-1.b14.fc23.i686 @updates
Install java-1.8.0-openjdk-headless-1:1.8.0.102-1.b14.fc23.i686 @updates
======================================================================================================================================================
Package Arch Version Repository Size
======================================================================================================================================================
Removing:
giflib i686 4.1.6-14.fc23 @fedora 86 k
java-1.8.0-openjdk i686 1:1.8.0.102-1.b14.fc23 @updates 503 k
java-1.8.0-openjdk-headless i686 1:1.8.0.102-1.b14.fc23 @updates 101 M
Transaction Summary
======================================================================================================================================================
Remove 3 Packages
Installed size: 102 M
Is this ok [y/N]:
Undo DNF Fails Link to heading
Note: This section currently only applies to CentOS. A similar solution should work on Fedora using their repositories.
If you're undoing a transaction that upgraded a package instead of installing a package then the package manager needs to be able to locate an older version of each package. This can be done by enabling the vault repository for your distribution as explained below (OS used in example is CentOS 6.5).
- Create new repository file
vim /etc/yum.repos.d/CentOS-Vault.repo
- Populate with the following information
[C6.5-base-vault]
name=CentOS-6.5 - Base - Vault
baseurl=[http://vault.centos.org/6.5/os/x86_64/](http://vault.centos.org/6.5/os/x86_64/)
enabled=1
The undo command should now be able to find the appropriate packages to roll back to.