How to use yum to downgrade or rollback some package updates?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 5.4 and later
  • Red Hat Enterprise Linux 6
  • Red Hat Enterprise Linux 7

Issue

  • How to rollback or downgrade installed package to previous version?
  • How to use yum to downgrade or rollback some package updates?
  • What is the best practice for rollback package ?
  • How to use yum downgrade option ?
  • Is it possible to find the OS update history for transactions performed with yum ?
  • Hot to downgrade my java version to 1.8.0.252?

Resolution

Warning: Rollback or downgrade of the following packages is unsupported as the packages themselves, and dependencies, either assume an update-only or install-only process:

  • dbus
  • kernel
  • glibc (dependencies of glibc such as gcc)
  • selinux-policy*

Thus, downgrading a system to minor version (ex: RHEL6.1 to RHEL6.0) is not recommended as this might leave the system in an undesired state. If this operation is attempted, it is strongly recommended to only do so with working system backups in place. In general, use the yum history option is intended for small update rollbacks.

Please read the following guides for additional information:

Red Hat Enterprise Linux 5 :

  • In Yum 3.2.22, which come with Red Hat Enterprise Linux 5.4, there is a downgrade option. This will downgrade a package to the previously highest version or you can specify the whole version and release number for the package to downgrade. For example:

    [root@host ~]# yum downgrade vsftpd-2.0.5-12.el5
    
  • Note that this may also remove the packages that depends on the current version of the package. Usually, for some closely related packages, you may want to downgrade them all together. Otherwise, yum will remove the closely related packages in order to satisfy the dependency requirement.

  • For example, if you want to downgrade httpd :

    [root@host ~]# yum downgrade httpd-2.2.3-22.el5
    [snip]
    Dependencies Resolved
    
    ========================================================================================================================
     Package                     Arch                Version                        Repository                         Size
    ========================================================================================================================
    Installing:
     httpd                       i386                2.2.3-22.el5                   rhel-i386-server-5                1.2 M
    Removing:
     httpd                       i386                2.2.3-31.el5                   installed                         3.1 M
    Removing for dependencies:
     httpd-manual                i386                2.2.3-31.el5                   installed                         3.4 M
     mod_ssl                     i386                1:2.2.3-31.el5                 installed                         173 k
    
    Transaction Summary
    ========================================================================================================================
    Install      1 Package(s)         
    Update       0 Package(s)         
    Remove       3 Package(s)    
    
    Total download size: 1.2 M
    Is this ok [y/N]:
    
  • The httpd-manual and mod_ssl packages will also be removed (instead of downgrade) because the downgraded httpd cannot satisfy the dependency of the current version httpd-manual and mod_ssl.

  • To downgrade them altogether, you can add them in the command:

    [root@host ~]# yum downgrade httpd-2.2.3-22.el5 httpd-manual-2.2.3-22.el5 mod_ssl-2.2.3-22.el5
    
    Dependencies Resolved
    
    ========================================================================================================================
     Package                     Arch                Version                        Repository                         Size
    ========================================================================================================================
    Installing:
     httpd                       i386                2.2.3-22.el5                   rhel-i386-server-5                1.2 M
     httpd-manual                i386                2.2.3-22.el5                   rhel-i386-server-5                833 k
     mod_ssl                     i386                1:2.2.3-22.el5                 rhel-i386-server-5                 87 k
    Removing:
     httpd                       i386                2.2.3-31.el5                   installed                         3.1 M
     httpd-manual                i386                2.2.3-31.el5                   installed                         3.4 M
     mod_ssl                     i386                1:2.2.3-31.el5                 installed                         173 k
    
    Transaction Summary
    ========================================================================================================================
    Install      3 Package(s)         
    Update       0 Package(s)         
    Remove       3 Package(s)   
    
    Total download size: 2.1 M
    Is this ok [y/N]:
    
  • Here we can see that the newer version of httpd, httpd-manual and mod_ssl altogether are reinstalled with the older version of those RPMs, and no package is going to be removed for dependencies.

  • Problems with performing downgrad :

    • Downgrades are tricky but in yum versions 3.2.27 and above it can do _some_ downgrades. They are not perfect and should be used with care
    • Refer to yum.baseurl.org for more details.

Red Hat Enterprise Linux 6 and 7 :

  • yum stores a sqlite database of information about each transaction. The history is organized terms of transaction ids and is updated every time a yum transaction affects the package configuration of the system. Mostly this database can be found in the /var/lib/yum/history/ directory.

  • The yum history command allows the user to view the history of transactions.

  • The following command lists the history of all transactions :-

# yum history list all
  • This will list the transaction ID along with the date and time, the actions performed and the number of packages altered :-

  • For more information on a particular transaction, note the transaction ID for that transaction and use it in the below command :-

# yum history info <transaction_ID>

Note : You can also use Red Hat Network Satellite to rollback or downgrade packages, please see : How to use Red Hat Network Satellite to rollback packages on a Red Hat Enterprise Linux system?.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

7 Comments

when I try your command. I get:
[root@usatlelaweb01 ~]# yum downgrade php-5.4
Loaded plugins: downloadonly, rhnplugin, security
Setting up Downgrade Process
ftp://mirror.cs.princeton.edu/pub/mirrors/fedora-epel/5/i386/repodata/repomd.xml: [Errno 4] IOError: [Errno ftp error] (111, 'Connection refused')
Trying other mirror.
epel | 3.6 kB 00:00
epel-source | 3.0 kB 00:00
remi | 2.5 kB 00:00
rhel5_32_base_20131231 | 1.3 kB 00:00
No package php-5.4 available.
Nothing to do
[root@usatlelaweb01 ~]#

ID | Login user | Date and time | Action(s) | Altered

24 | root <root>              | 2014-06-18 15:47 | I, U           |  281 E<

Sorry for not responding sooner but I had to find another workaround. The yum downgrade did not work for me as it wanted to remove/downgrade dependencies that would have broken other parts of the O/S. I couldn't risk corrupting the entire server trying to downgrade firefox.

Downgrade doesn't work in RHEL 6, I tried to downgrade sudo but failed

yum downgrade sudo-1.8.6p3-15.el6
Loaded plugins: product-id, refresh-packagekit
Setting up Downgrade Process
Nothing to do

This is missleading for RHEL 5/6 users. How does it compare to this previous statement ? https://access.redhat.com/solutions/144223

I downloaded Red enterprise 7.4 I am having a problem with yum not working can you help me Loaded plugins: langpacks, product-id, search-disabled-repos, subscription- : manager There are no enabled repos. Run "yum repolist all" to see the repos you have. To enable Red Hat Subscription Management repositories: subscription-manager repos --enable To enable custom repositories: yum-config-manager --enable [root@192 gd]# yum groupinstall "KDE" Loaded plugins: langpacks, product-id, search-disabled-repos, subscription- : manager There are no enabled repos. Run "yum repolist all" to see the repos you have. To enable Red Hat Subscription Management repositories: subscription-manager repos --enable To enable custom repositories: yum-config-manager --enable

Can I downgrade from RHEL 8.2 to 7.x ..