It's annoying when you upgrade a package on Linux only to find out that the updated version is broken and doesn't work properly. In such cases, you might be tempted to completely remove the package from your system, but there's a better way to fix this issue.

On Linux-based operating systems, you can easily switch to older versions of packages using the default package manager. Here's how to downgrade packages on Linux and why you might need to.

Why Downgrade Packages?

Sometimes when developers release a new version of a package, it's available right away for the users to download. Most new software releases are often untested and contain bugs and issues that need fixing.

While it's completely normal in the open-source world for users to test the latest software and report bugs, you can instead choose to have a stable system by downgrading the updated package to its older tested version. This is mostly the case with bleeding-edge Linux distros like Arch Linux or its derivatives. On the other hand, many Linux distros offer stable releases which only contain tested and trusted packages in their repositories. Ubuntu and Debian (stable) are two good examples.

The downgrading feature comes in handy especially when you're using Linux to power a system that needs to be stable at its core. A server, for example. You can't compromise on the stability and count on an untested package when you're delivering resources to hundreds or thousands of users simultaneously over the web. In such situations, switching a package to its older stable version is the most viable route to maintain system stability.

How to Downgrade Packages on Linux

Every Linux distribution has a default package manager that allows you to switch to older package versions by downgrading them. On Debian-based distros, you have the APT package manager, whereas Arch Linux and RHEL-based distros ship with Pacman and RPM, respectively.

On Ubuntu and Debian

Downgrading a package on Ubuntu and other Debian-based distros is as easy as the installation process. All you need to know is the package name and the specific version number you want to install.

Assuming you already know which package to downgrade, you can get the package version details using the following command:

        apt list -a packagename
    

For example, let's find the available package versions for the GNOME Terminal:

        apt list -a gnome-terminal
    

Output:

get package versions on ubuntu

The output will display all the versions of the specified package currently available in the repositories. Note down the second value ("3.36.1.1-1ubuntu1," in this case) in the output corresponding to the version you want to switch to and specify it in the following command format:

        sudo apt install packagename=version
    

To downgrade the gnome-terminal package to the older "3.36.1.1-1ubuntu1" version:

        sudo apt install gnome-terminal=3.36.1.1-1ubuntu1
    

Output:

downgrading a package on ubuntu

APT will warn you about the downgrade process. Confirm the change by entering "Y" and hitting Enter.

You can verify if APT successfully downgraded the package using the --version flag:

        gnome-terminal --version
    

If the output displays a version number older than the latest release, the package was successfully downgraded and you can continue using it as usual.

Downgrade Packages on Arch Linux

On Arch Linux, you can switch to an older version of a package installed earlier using the saved Pacman cache. The package cache is a directory on an Arch-based system that stores every package you download on your machine. The packages aren't removed from the package cache unless specified.

Cleaning the package cache is a good way to free some space on your Linux desktop.

To do this, search for the cached package file stored under the /var/cache/pacman/pkg directory. Then, use the pacman command to install the older version of the package as follows:

        sudo pacman -U /var/cache/pacman/pkg/packagename-old.tar.zst
    

Downgrading packages from the cache isn't the best option, as it requires a lot of searching on your end. To make it easier, you can use the find command to perform the search instead.

An even better choice is using the downgrade utility. It's not available on Arch Linux by default and you'll have to download it from the AUR.

        yay -S downgrade
    

To downgrade a package on Arch-based distros using downgrade, issue the following command:

        sudo downgrade package
    

Output:

using downgrade on arch linux

The output will list all the package versions available to install. Choose from the options and enter the number corresponding to the package version to continue the installation of the older package.

On Fedora and RHEL

On RPM-based Linux distros like Fedora, CentOS, and Red Hat Enterprise Linux, there's a built-in feature in the YUM package manager that allows users to downgrade packages.

To downgrade a package using YUM, simply run:

        sudo yum downgrade packagename
    

For example, to downgrade the Firefox browser package:

        sudo yum downgrade firefox
    

Output:

downgrade package on fedora

The aforementioned command will switch to the previous latest version of the package.

To downgrade a package to a specific version, first, you'll need to know the exact version number. For this, you can head over to Fedora Koji Web and search for the package. It'll list all the available versions of the package.

All versions of a package might not be available in the official repositories. In such cases, you can download the RPM package from Fedora Koji Web and manually install it using the rpm command.

fedora kobi web packages

Simply note down the full package name and specify it in the downgrade command as follows:

        sudo yum downgrade pkgnamewithversion
    

To downgrade multiple packages in a single command, simply provide the package names separated with spaces:

        sudo yum downgrade package1 package2 package3
    

Maintaining Stability on Your Linux Desktop

Similar to Windows and other operating systems, packages on Linux have bugs that can even break your system if not taken care of. However, such issues are quickly resolved thanks to the helpful open-source community that tests these broken packages and reports bugs to the developers.

If you're dead set on installing a stable operating system, then you can rule out Arch Linux and other Arch-based distributions from the list. These are mostly bleeding-edge distros and provide updates to packages as soon as the latest version is released.

If you want a more stable desktop experience with Linux, consider installing distros that offer LTS releases like Ubuntu, Debian, Linux Mint, or openSUSE Leap.