The yum history
command is a powerful tool for system administrators to track and manage package installation and updates on Linux systems. This command provides detailed information about all Yum transactions, making it easier to troubleshoot issues, roll back changes, or audit system modifications.
In this guide, we’ll cover how to use the yum history
command, interpret its output, and perform specific actions like undoing a transaction.
What Does the yum history
Command Do?
The yum history
command allows sysadmins to view a historical record of Yum transactions, including:
- The dates and times of transactions.
- The number of packages affected.
- Whether transactions succeeded or were aborted.
- Changes to the RPM database between transactions.
- The ability to undo or redo specific transactions.
Viewing Yum Transaction History
To view the transaction history, run the following command:
sudo yum history
You’ll be prompted to enter your password. Once authenticated, you’ll see a table similar to this:
Loaded plugins: langpacks, product-id, search-disabled-repos
ID | Login user | Date and time | Action(s) | Altered
------------------------------------------------------------
48 | System <unset> | 2021-04-14 15:00 | Update | 10 <
47 | System <unset> | 2021-04-08 09:50 | E, I, U | 45 >E
46 | Jose ... <jose>| 2021-04-07 15:47 | Install | 23
45 | Jose ... <jose>| 2021-04-06 08:57 | Install | 1
Key Columns in the Output:
- ID: The transaction ID, which is unique for each operation.
- Login User: The user who initiated the transaction.
- Date and Time: When the transaction occurred.
- Action(s): The type of operation performed, such as
Install
,Update
, orErase
. - Altered: The number of packages affected by the transaction.
Viewing Detailed Information for a Specific Transaction
To get more details about a specific transaction, use its Transaction ID with the following command:
sudo yum history info <Transaction ID>
For example, to view details for Transaction ID 41:
sudo yum history info 41
This will output detailed information about the transaction, such as:
Transaction ID : 41
Begin time : Wed Mar 24 16:01:29 2021
End time : 16:01:30 2021 (1 seconds)
User : Jose Andres Navarro Varela <jose>
Command Line : -y install openvpn
Transaction performed with:
Installed rpm-4.11.3-45.el7.x86_64 @RHEL-79-x86_64
Installed yum-3.4.3-168.el7.noarch @RHEL-79-x86_64
Packages Altered:
Install openvpn-2.4.10-1.el7.x86_64 @epel
Dep-Install pkcs11-helper-1.11-3.el7.x86_64 @epel
Return-Code : Success
This information provides a clear picture of what was installed or updated during the transaction.
Undoing a Transaction
If you need to undo a specific transaction, you can use the following command:
sudo yum history undo <Transaction ID>
For example, to undo Transaction ID 41:
sudo yum history undo 41
This will revert the changes made during that transaction. Note that some transactions may not be fully reversible, especially if subsequent transactions depend on them.
Practical Use Cases for yum history
- Troubleshooting Package Issues: Identify when a problematic package was installed or updated.
- Auditing Changes: Track who made changes to the system and when.
- Rolling Back Updates: Undo a failed or unnecessary update.
- Package Dependency Management: Understand the dependencies that were installed or removed during a transaction.
Additional Resources
For more information, refer to the official Yum documentation:
Conclusion
The yum history
command is an essential tool for managing and troubleshooting package installations and updates on Linux systems. By leveraging its features, you can maintain better control over your system’s package management and ensure stability across your environment.