How to Rollback updates with yum history command on CentOS / RHEL Servers

One of the important task of Linux system administrator is to update packages on the servers. There can be some scenarios where Linux admin apply updates on servers but after applying updates application hosted on the server might not work properly due to incompatibility of new updates, In that case we don’t have any option but to rollback updates.

As we know that on Linux servers (RHEL & CentOS) updates are applied with yum command and updates can be rollback with “yum history command“.

Let’s assume i have a Apache Web Server running on CentOS 6.x/7.x or RHEL 6.x/7.x. I got the requirement from development to update the existing “httpd” package to the latest one.

Updating Package on RHEL / CentOS Servers

Let’s first verify the existing http package version using beneath command

[root@linuxtechi ~]# rpm -q httpd
httpd-2.4.6-40.el7.centos.x86_64
[root@linuxtechi ~]#

Use below command to see the latest available httpd package

[root@linuxtechi ~]# yum list httpd

yum-list-command-output

Run the beneath command to update httpd package from 2.4.6-40 to 2.4.6-45

[root@linuxtechi ~]# yum update httpd

yum-update-httpd

Verify new version of httpd package

[root@linuxtechi ~]# rpm -q httpd
httpd-2.4.6-45.el7.centos.x86_64
[root@linuxtechi ~]#

Rollback updates on CentOS 6.x/7.x and RHEL 6.x/7.x Servers

In above steps we have updated the httpd package but due to compatibility issue we have to rollback httpd to previous version, this can be achieved using yum history command.

Let’s get the transaction id which was used for updating the httpd package

[root@linuxtechi ~]# yum history list all

yum-history-all-command

As per the above output we will get details like when was the update action performed along the transaction id.

Use below yum command to find what was actually updated against the transaction id

[root@linuxtechi ~]# yum history info 3

yum-history-info-command

Now Rollback httpd package to the previous version using following command

[root@linuxtechi ~]# yum history undo 3

yum-history-undo

Once the above yum command is executed successfully verify the httpd package version

[root@linuxtechi ~]# rpm -q httpd
httpd-2.4.6-40.el7.centos.x86_64
[root@linuxtechi ~]#

Note: In Case of RHEL 5.x and CentOS 5.x we can downgrade and rollback packages using downgrade option in yum command, example is shown below

[root@linuxtechi ~]# yum downgrade httpd-2.2.3-91.el5 httpd-manual-2.2.3-91.el5 mod_ssl-2.2.3-91.el5

That’s all for this tutorial.Please share your feedback and comments.

3 Responses

  1. Brian T. says:

    This is helpful. Thank you. I had a similar situation, but I wasn’t able to track down when the initial change happened, so I don’t think these steps would help. Let’s say instead of “undoing” an update that we want to downgrade to a previous package. I think my distro version had the latest version of a package, Java, and I wanted to downgrade to an earlier version. Can you explain how to do this?

    • Hi Brain,

      You can use downgrade option in yum command but for that you have to make sure earlier Java version rpm package should be available in your yum repository.
      # yum downgrade java-{version}

      Yum command also stores all its transaction in sqlite database, using “yum history list all” you can check all yum updates history along with time.

  2. Mushtaque says:

    Can we follow this for patch roll back too…

Leave a Reply

Your email address will not be published. Required fields are marked *