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

Channel: Linux
Abstract: [[email protected] ~]# Use below command to see the latest available httpd package [[email protected] ~]# yum list httpd Run the beneath command to up

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

[[email protected] ~]# rpm -q httpd
httpd-2.4.6-40.el7.centos.x86_64
[[email protected] ~]#

Use below command to see the latest available httpd package

[[email protected] ~]# yum list httpd

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

[[email protected] ~]# yum update httpd

Verify new version of httpd package

[[email protected] ~]# rpm -q httpd
httpd-2.4.6-45.el7.centos.x86_64
[[email protected] ~]#
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

[[email protected] ~]# yum history list all

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

[[email protected] ~]# yum history info 3

Now Rollback httpd package to the previous version using following command

[[email protected] ~]# yum history undo 3

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

[[email protected] ~]# rpm -q httpd
httpd-2.4.6-40.el7.centos.x86_64
[[email protected] ~]#

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

[[email protected] ~]# 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.

Ref From: linuxtechi

Related articles