Posted on
Administration

Downgrading a package in DNF

Author
  • User
    Linux Bash
    Posts by this author
    Posts by this author

How to Downgrade a Package in Linux Using DNF, APT, and Zypper

If you've upgraded a software package on your Linux system only to find out the new version has bugs or compatibility issues, reverting to a previous version can resolve the problem. Different Linux distributions use different package managers, and the methods to downgrade software vary accordingly. In this blog, we'll go over how to downgrade a package if you are using DNF, APT, or Zypper as your package manager.

DNF (Fedora, RHEL, CentOS)

DNF (Dandified YUM) is the next-generation version of YUM and is the default package manager for Fedora. If you need to downgrade a package in Fedora or any other system that uses DNF, you can use the following steps:

  1. Find the Version Number: First, you'll need to find out which versions of the package are available. You can search the available versions of the package by:

    dnf --showduplicates list <package-name>
    

    Replace <package-name> with the actual name of the package.

  2. Downgrade the Package: Once you have identified the version to which you want to downgrade, use the downgrade command:

    sudo dnf downgrade <package-name-version-release>
    

    Ensure to replace <package-name-version-release> with the full version/release descriptor shown in the list (e.g., httpd-2.4.37-16.fc30).

  3. Check Installation: Verify that the downgrade was successful by checking the version of the installed package:

    dnf info <package-name>
    

APT (Debian, Ubuntu)

APT (Advanced Package Tool) is commonly used in Debian-based systems like Ubuntu. Here’s how you can downgrade a package using APT:

  1. Find the Version Number: Similar to DNF, start by finding the available versions of the package:

    apt list -a <package-name>
    
  2. Downgrade the Package: After deciding which version to revert to, use the apt-get install command followed by the package name and the version number:

    sudo apt-get install <package-name>=<version>
    

    Replace <package-name> and <version> accordingly.

  3. Hold the Package: To prevent the package from being updated again in a future update, hold the package:

    sudo apt-mark hold <package-name>
    

Zypper (openSUSE, SUSE)

Zypper is the command line interface of ZYpp package manager for installing, removing, and managing packages in openSUSE and SUSE systems.

  1. Find the Version Number: First, search for all available versions of the package:

    zypper se -s <package-name>
    
  2. Downgrade the Package: To downgrade to an earlier version, use:

    sudo zypper install <package-name>=<older-version>
    

    Make sure to specify the full package name and version.

  3. Verify the Downgrade: Lastly, verify that the correct version has been installed:

    zypper info <package-name>
    

Conclusion

Downgrading a package in Linux requires specific commands depending on the package manager your Linux distribution uses. Whether you're a Fedora, Debian, or openSUSE user, following the correct procedure will ensure that you successfully revert a package to a previous version without breaking dependencies or affecting other system components. Always make sure to check the compatibility of downgraded packages with your current system environment.