Chapter 8. Handling package management history
With the dnf history
command, you can review the following information:
- Timeline of DNF 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 the transactions.
8.1. Listing DNF transactions
You can use the DNF software management tool to 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 history
# dnf history
Copy to Clipboard Copied! The 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
Altered
column 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)
andAltered
columns, 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>
# dnf history list <package_name>
Copy to Clipboard Copied! To display details of a particular transaction, enter:
dnf history info <transaction_id>
# dnf history info <transaction_id>
Copy to Clipboard Copied!
You can filter the results by appending global expressions as arguments. For more details, see Specifying global expressions in DNF input.
8.2. Reverting DNF transactions
Reverting a DNF transaction can be useful if you want to undo operations performed during the transaction. For example, if you installed several packages by using the dnf install
command, you can uninstall these packages at once by reverting an installation transaction.
You can revert DNF transactions the following ways:
-
Revert a single DNF transaction by using the
dnf history undo
command. -
Revert all DNF transactions performed between the specified transaction and the last transaction by using the
dnf history rollback
command.
8.2.1. Reverting a single DNF transaction
You can revert steps performed within a single transaction by using the dnf history undo
command:
-
If the transaction installed a new package,
dnf history undo
uninstalls the package. -
If the transaction uninstalled a package,
dnf history undo
reinstalls the package. The
dnf history undo
command 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 undo
command fails.
Procedure
Identify the ID of a transaction you want to revert:
dnf history
# dnf history ID | 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 | 1
Copy to Clipboard Copied! Optional: Verify that this is the transaction you want to revert by displaying its details:
dnf history info <transaction_id>
# dnf history info <transaction_id>
Copy to Clipboard Copied! Revert the transaction:
dnf history undo <transaction_id>
# dnf history undo <transaction_id>
Copy to Clipboard Copied! For example, if you want to uninstall the previously installed
unzip
package, enter:dnf history undo 12
# dnf history undo 12
Copy to Clipboard Copied!
8.2.2. Reverting multiple DNF transactions
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 history
# dnf history ID | 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 EE
Copy to Clipboard Copied! Revert specified transactions:
dnf history rollback <transaction_id>
# dnf history rollback <transaction_id>
Copy to Clipboard Copied! For example, to revert to the state before the
wget
andunzip
packages were installed, enter:dnf history rollback 12
# dnf history rollback 12
Copy to Clipboard Copied! Alternatively, to revert all transactions in the transaction history, use the transaction ID 1:
dnf history rollback 1
# dnf history rollback 1
Copy to Clipboard Copied!