Introduction
Installing system updates is important for keeping a CentOS server secure and up to date. However, in some situations, a newly installed package or update may cause an application or system functionality to stop working correctly.
When the problem is directly related to a recent YUM transaction, you may be able to revert that transaction using YUM history.
Important: A YUM rollback should be performed carefully on production systems. Always review the transaction before confirming the changes, and take a backup or snapshot where possible.
Prerequisites
Before rolling back a YUM transaction, make sure:
- You have root or sudo access to the CentOS server.
- The system uses YUM for package management.
- You know approximately when the problematic update or installation was performed.
- You have identified the YUM transaction that needs to be reverted.
- A recent backup or server snapshot is available, especially for production systems.
Implementation
Step 1: Check YUM History
First, list the previous YUM transactions:
sudo yum history
A sample output may look like:
ID | Login user | Date and time | Action(s) | Altered ------------------------------------------------------- 17 | root | 2017-06-16 03:30 | Install | 2 16 | root | 2017-06-16 03:28 | Install | 63 15 | root | 2017-06-16 03:20 | Install | 8 14 | root | 2017-06-15 06:18 | Install | 1 13 | root | 2017-06-14 02:50 | Install | 2 12 | root | 2017-06-12 03:43 | I, U | 9
Identify the transaction ID corresponding to the update or package installation that caused the issue.
Step 2: Review the Transaction
Before undoing a transaction, review its details.
For example, if the transaction ID is 17:
sudo yum history info 17
This allows you to see which packages were installed, updated, or removed during that transaction.
Review the transaction carefully before proceeding.
Step 3: Undo the YUM Transaction
Once you have confirmed the correct transaction ID, use:
sudo yum history undo 17
Replace 17 with the actual transaction ID.
YUM will calculate the changes required to reverse the selected transaction.
Review the packages that YUM proposes to change before confirming.
Step 4: Confirm the Rollback
If the proposed transaction is correct, confirm it when prompted.
YUM will then attempt to reverse the changes made by the selected transaction.
Step 5: Verify the System
After the rollback completes, verify the affected application or service.
You can also check the YUM history again:
sudo yum history
If a service was affected, check its status:
sudo systemctl status SERVICE_NAME
Replace SERVICE_NAME with the affected service.
Conclusion
YUM provides transaction history that can help administrators identify and reverse recent package changes.
The basic workflow is:
sudo yum history sudo yum history info <ID> sudo yum history undo <ID>
Always review the transaction before confirming a rollback, and take a backup or server snapshot before making significant changes to a production system.
Frequently Asked Questions
1. How do I see previous YUM transactions?
Run:
sudo yum history
This displays previous package-management transactions along with their transaction IDs.
2. How do I check what packages were changed in a YUM transaction?
Use:
sudo yum history info <ID>
For example:
sudo yum history info 17