Chapter 8. Handling package management history
Track and manage software changes on your Red Hat Enterprise Linux (RHEL) 10 systems by using the DNF history database. By reviewing or reverting past transactions, you can quickly recover from accidental configuration changes.
You can perform various operations on the package management history by using the dnf history command. You can review the following information related to the DNF transactions:
- Timeline of transactions.
- Dates and times the transactions occurred.
- Number of packages affected by the transactions.
- Whether the transactions succeeded or were aborted.
- If the RPM database was changed between the transactions.
You can also use the dnf history command to undo operations performed during the transaction.
8.1. Listing DNF transactions Copy linkLink copied to clipboard!
To audit software changes or identify specific package operations, list the package management history on Red Hat Enterprise Linux (RHEL) 10 by using the DNF tool. Reviewing these transactions ensures you have a clear record of system modifications for maintenance and troubleshooting purposes.
By using the DNF tool, you can perform the following tasks:
- List the latest transactions.
- List the latest operations for a selected package.
- Display details of a particular transaction.
Procedure
Depending on your scenario, use one of the following options to display transaction information:
To display a list of all the latest DNF transactions, enter:
# dnf historyThe output contains the following information:
-
The
Action(s)column displays which type of action was performed during a transaction, for example, Install (I), Upgrade (U), Remove (E), and other actions. The
Alteredcolumn displays the number of actions performed during the transaction. The number of actions can also be followed by the result of the transaction.For more information about the values of the
Action(s)andAlteredcolumns, see thednf(8)man page.
-
The
To display a list of all the latest operations for a selected package, enter:
# dnf history list <package_name>To display details of a particular transaction, enter:
# dnf history info <transaction_ID>
8.2. Reverting DNF transactions Copy linkLink copied to clipboard!
To undo operations performed during DNF transactions on Red Hat Enterprise Linux (RHEL) 10, revert these transactions by using the DNF tool. By reverting transactions, you can quickly restore your system to a previous state. For example, if you installed several packages by using the dnf install command, you can uninstall these packages at once by reverting the installation transaction.
You can revert DNF transactions the following ways:
-
Revert a single DNF transaction by using the
dnf history undocommand. -
Revert all DNF transactions performed between the specified transaction and the last transaction by using the
dnf history rollbackcommand.
Downgrading RHEL system packages to an older version by using the dnf history undo and dnf history rollback command is not supported. This concerns especially the selinux, selinux-policy-*, kernel, and glibc packages, and dependencies of glibc such as gcc. Therefore, downgrading a system to a minor version (for example, from RHEL 10.1 to RHEL 10.0) is not recommended because it might leave the system in an incorrect state.
8.2.1. Reverting a single DNF transaction Copy linkLink copied to clipboard!
To undo operations performed during a single DNF transaction on Red Hat Enterprise Linux (RHEL) 10, revert this transaction by using the DNF tool. By reverting the environment to a specific point in your package management history, you can recover from accidental changes and errors. Reverting a single transaction in DNF history will not undo or modify more recent transactions.
You can revert the transaction’s steps by using the dnf history undo command:
-
If the transaction installed a new package,
dnf history undouninstalls the package. -
If the transaction uninstalled a package,
dnf history undoreinstalls the package. The
dnf history undocommand also attempts to downgrade all updated packages to their previous versions if the older packages are still available.NoteIf an older package version is not available, the downgrade by using the
dnf history undocommand fails.
Procedure
Identify the ID of a transaction you want to revert:
# dnf historyID | Command line | Date and time | Action(s) | Altered -------------------------------------------------------------------- 13 | install zip | 2022-11-03 10:49 | Install | 1 12 | install unzip | 2022-11-03 10:49 | Install | 1Optional: Verify that this is the transaction you want to revert by displaying its details:
# dnf history info <transaction_ID>Revert the transaction:
# dnf history undo <transaction_ID>For example, if you want to uninstall the previously installed
unzippackage, enter:# dnf history undo 12
8.2.2. Reverting multiple DNF transactions Copy linkLink copied to clipboard!
To undo operations performed during DNF transactions on Red Hat Enterprise Linux (RHEL) 10, revert these transactions by using the DNF tool. By reverting the environment to a specific point in your package management history, you can recover from accidental changes and errors.
You can revert all DNF transactions performed between a specified transaction and the last transaction by using the dnf history rollback command. Note that the transaction specified by the transaction ID remains unchanged.
Procedure
Identify the transaction ID of the state you want to revert to:
# dnf historyID | Command line | Date and time | Action(s) | Altered ------------------------------------------------------------------ 14 | install wget | 2022-11-03 10:49 | Install | 1 13 | install unzip | 2022-11-03 10:49 | Install | 1 12 | install vim-X11 | 2022-11-03 10:20 | Install | 171 EERevert specified transactions:
# dnf history rollback <transaction_ID>For example, to revert to the state before the
wgetandunzippackages were installed, enter:# dnf history rollback 12Alternatively, to revert all transactions in the transaction history, use the transaction ID
1:# dnf history rollback 1