Chapter 9. Handling package management history
With the yum history command, you can review the following information:
- Timeline of YUM 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 yum history command to undo the transactions.
9.1. Listing transactions Copiar o linkLink copiado para a área de transferência!
You can use YUM 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 YUM transactions, enter:
yum history
# yum historyCopy to Clipboard Copied! Toggle word wrap Toggle overflow 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
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 theyum(8)man page on your system.
-
The
To display a list of all the latest operations for a selected package, enter:
yum history list <package_name>
# yum history list <package_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow To display details of a particular transaction, enter:
yum history info <transaction_id>
# yum history info <transaction_id>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
You can filter the results by appending global expressions as arguments. For more details, see Specifying global expressions in yum input.
9.2. Reverting YUM transactions Copiar o linkLink copiado para a área de transferência!
Reverting a YUM transaction can be useful if you want to undo operations performed during the transaction. For example, if you installed several packages by using the yum install command, you can uninstall these packages at once by reverting an installation transaction.
You can revert YUM transactions the following ways:
-
Revert a single YUM transaction by using the
yum history undocommand. -
Revert all YUM transactions performed between the specified transaction and the last transaction by using the
yum history rollbackcommand.
Downgrading RHEL system packages to an older version by using the yum history undo and yum 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 8.1 to RHEL 8.0) is not recommended because it might leave the system in an incorrect state.
9.2.1. Reverting a single YUM transaction Copiar o linkLink copiado para a área de transferência!
You can revert steps performed within a single transaction by using the yum history undo command:
-
If the transaction installed a new package,
yum history undouninstalls the package. -
If the transaction uninstalled a package,
yum history undoreinstalls the package. -
The
yum history undocommand also attempts to downgrade all updated packages to their previous versions if the older packages are still available.
If an older package version is not available, the downgrade by using the yum history undo command fails.
Procedure
Identify the ID of a transaction you want to revert:
yum history
# yum 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 | 1Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Verify that this is the transaction you want to revert by displaying its details:
yum history info <transaction_id>
# yum history info <transaction_id>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Revert the transaction:
yum history undo <transaction_id>
# yum history undo <transaction_id>Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example, if you want to uninstall the previously installed
unzippackage, enter:yum history undo 12
# yum history undo 12Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you want to revert the last transaction, enter:
yum history undo last
# yum history undo lastCopy to Clipboard Copied! Toggle word wrap Toggle overflow
9.2.2. Reverting multiple YUM transactions Copiar o linkLink copiado para a área de transferência!
You can revert all YUM transactions performed between a specified transaction and the last transaction by using the yum 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:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Revert specified transactions:
yum history rollback <transaction_id>
# yum history rollback <transaction_id>Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example, to revert to the state before the
wgetandunzippackages were installed, enter:yum history rollback 12
# yum history rollback 12Copy to Clipboard Copied! Toggle word wrap Toggle overflow Alternatively, to revert all transactions in the transaction history, use the transaction ID 1:
yum history rollback 1
# yum history rollback 1Copy to Clipboard Copied! Toggle word wrap Toggle overflow