Reverting a system update or package update on CentOS, Rocky Linux or AlmaLinux using yum is a bit different compared to other package managers, as yum doesn’t have a direct “revert last update” command. However, you can undo a specific update transaction by using the yum history command. Before you start please perform a backup or snapshot of the system before attempting any rollbacks. This is crucial in case the reversion process encounters issues or causes dependency conflicts. Here’s how you can revert the last update:

1. Check the Update History

First, list the recent yum transactions to find the ID of the last update:

  yum history
  

This command will display a list of recent transactions, including the transaction IDs (TID), dates, and descriptions of what was done.

Example output:

  ID     | Command line             | Date and time    | Action(s)      | Altered
--------------------------------------------------------------------------------
50     | update                   | 2024-08-19 10:32 | Update         |    12
49     | install httpd            | 2024-08-18 09:20 | Install        |     1
48     | update                   | 2024-08-17 15:10 | Update         |     8
  

2. Revert the Last Update

Once you’ve identified the transaction ID of the last update (e.g., 50), you can undo it using the following command:

  sudo yum history undo 50
  

This command will attempt to reverse all the package changes made in that update transaction. Replace 50 with the ID you want. yum will uninstall the updated packages and reinstall the previous versions.

3. Review the Changes

After running the undo command, yum will list the packages that will be downgraded, removed, or installed. Review this list carefully to ensure it matches what you expect.

4. Confirm the Reversion

If the changes look good, confirm the action. yum will proceed to revert the updates.

5. Verify the Reversion

After the process completes, you can verify that the system has reverted to the previous state by checking the package versions:

  yum list installed <package_name>
  

Replace <package_name> with the name of a package that was updated in the last transaction.

Additional Tips

  • Partial Rollback: If you don’t want to undo the entire transaction but just a few specific packages, you can specify them in the undo command:
  sudo yum history undo 50 <package_name>
  
  • History Info: If you need more details about a specific transaction, you can use:
  yum history info 50
  
  • Reapply a reverted update: Consider using yum history redo to reapply a reverted update if the rollback introduces further problems.

  • Use with Caution: While yum history undo is a powerful feature, it may not always perfectly revert changes, especially if other package dependencies were altered or new packages were installed after the update.

By following these steps, you should be able to successfully revert the last update on a Linux RHEL system using yum.

Conclusion

Reverting updates on CentOS, Rocky Linux, or AlmaLinux using yum can be a straightforward process if approached with caution and a clear understanding of the system’s package history. By using the yum history command and carefully selecting the transaction to undo, you can restore your system to a stable state when updates cause issues. However, always review the changes, backup your system, and be mindful of potential dependency conflicts before proceeding. With these best practices in place, you can confidently manage and maintain your Linux environment using yum’s history features.