I want to downgrade a couple RPMs. Is there a switch combination for that? For example, when upgrading, I usually run rpm -Uvh foo.rpm but my understanding is that the -U switch means that it only replace the package if it's older... so it won't work for downgrades.

  • Are you using YUM to do this work or do you have the RPM files locally already? I'd attempt using yum downgrade <package>. – slm Aug 27 '14 at 15:49
  • @slm local rpm files. – Mike B Aug 27 '14 at 16:12

Using RPM

Try the following:

$ rpm -Uvh --oldpackage pkg1.rpm pkg2.rpm

excerpt from rpm man page

   rpm {-U|--upgrade} [install-options] PACKAGE_FILE ...

   This upgrades or installs the package currently installed to a newer 
   version.  This is the same as install, except all other version(s) of the  
   package are removed after the new package is installed.

          Allow an upgrade to replace a newer package with an older one.

Using YUM + downgrade

With yum you should be able to do the following as well:

$ yum downgrade /path/pkg1.rpm /path/pkg2.rpm

Using YUM + history undo

If you previously had pkgX-1.0 installed and then upgraded it to pkgX-1.1, you should be able to use yum history to see this upgrade and yum history undo to revert this too.

excerpt from yum man page on history

The undo/redo/rollback commands take either a single transaction id or the keyword last and an offset from the last transaction (Eg. if you've done 250 transactions, "last" refers to transaction 250, and "last-4" refers to transaction 246). The redo command can also take some optional arguments before you specify the transaction. "force-reinstall" tells it reinstall any packages that were installed in that transaction (via install, upgrade or downgrade). "force-remove" tells it to forcibly remove any packages that were updated or downgraded.

The undo/redo commands act on the specified transaction, undo'ing or repeating the work of that transaction. While the rollback command will undo all transactions up to the point of the specified transaction. For example, if you have 3 transactions, where package A; B and C where installed respectively. Then "undo 1" will try to remove package A, "redo 1" will try to install package A (if it is not still installed), and "rollback 1" will try to remove packages B and C. Note that after a "rollback 1" you will have a fourth transaction, although the ending rpmdb version (see: yum version) should be the same in transactions 1 and 4.

To see your YUM history:

$ sudo yum history | head
Loaded plugins: fastestmirror, langpacks, refresh-packagekit
ID     | Command line             | Date and time    | Action(s)      | Altered
   120 | install httpd            | 2014-08-26 09:19 | Install        |    5   
   119 | install pydf             | 2014-08-22 17:11 | Install        |    1   
   118 | install xsel             | 2014-08-22 13:29 | Install        |    1   
   117 | install pastebinit       | 2014-08-22 13:26 | Install        |    2   
   116 | install xorg-x11-apps-0: | 2014-08-21 11:04 | Install        |    2   
   115 | remove adobe-release-x86 | 2014-08-21 02:18 | Erase          |    1   
   114 | update                   | 2014-08-21 02:15 | E, I, O, U     |   67  <

To undo a particular transaction:

$ sudo yum history undo 120
Loaded plugins: fastestmirror, langpacks, refresh-packagekit, tsflags
Undoing transaction 120, from Tue Aug 26 09:19:17 2014
    Dep-Install apr-1.5.1-1.fc20.x86_64                 @updates
    Dep-Install apr-util-1.5.3-1.fc20.x86_64            @updates
    Dep-Install fedora-logos-httpd-21.0.1-1.fc20.noarch @fedora
    Install     httpd-2.4.10-1.fc20.x86_64              @updates
    Dep-Install httpd-tools-2.4.10-1.fc20.x86_64        @updates
Resolving Dependencies
--> Running transaction check
---> Package apr.x86_64 0:1.5.1-1.fc20 will be erased
---> Package apr-util.x86_64 0:1.5.3-1.fc20 will be erased
---> Package fedora-logos-httpd.noarch 0:21.0.1-1.fc20 will be erased
---> Package httpd.x86_64 0:2.4.10-1.fc20 will be erased
---> Package httpd-tools.x86_64 0:2.4.10-1.fc20 will be erased
--> Finished Dependency Resolution
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.