Sometimes Linux packages break. A new update goes through, yet it wasn’t tested well. Maybe you’re running a bleeding edge distribution or a strange custom configuration. You could even just want to keep an older version of a package around for testing or to hold back a change.
There are plenty of reasons that you’d want to roll your Linux install back to an earlier version of a package. The process is dependent on your distribution’s package manager, but it should be possible in most cases.
Apt is one of the most beloved package managers in the Linux world, but in this case it’s easily one of the most awkward and cumbersome options to work with. Apt doesn’t have any set mechanisms to roll back packages, and it doesn’t have a caching system that you can really count on in these situations. That said, you can usually find a way to install an older version of a package.
sudo apt-cache showpkg firefox
That will spit out a whole lot of info that you probably don’t need, but it will also show you previously installed versions of the package or additional versions.
Once you have a package selected, install it by specifying the version.
sudo apt install firefox=60.1
There’s another option here. If you can find an older version of a package that you want, you can download it separately and install it with
dpkg (more on dpkg here). You can even find them from an older release of your distribution. For example, if you’re running Ubuntu Bionic, you can install a package from Xenial. In that case you can do something like the following:
sudo dpkg -i firefox-60.1.deb
Fedora’s DNF package manager has a couple of very useful mechanisms built in that allow you to install a previous version of a package or roll back past any change or upgrade.
First, and probably most simply, you can install a previous version of a package from DNF’s repositories. Begin by listing all available options.
sudo dnf --showduplicates list package_name
DNF will present you with all versions of the package in your enabled repositories. Pick the one you want, and install it by specifying the version number to DNF.
sudo dnf install package_name-version.fc28
DNF will install the version of the package that you specified over the existing version.
As mentioned earlier, DNF keeps a complete history with snapshots. You can use that history to revert your system to an earlier state. Begin by listing DNF’s history.
sudo dnf history
It should be easy to find the point you want to return to, but you can easily get information on a DNF transaction with its ID number.
sudo dnf history info 42
When you’re sure you have the right one, undo the transaction.
sudo dnf history undo 42
DNF will reverse that transaction, returning your system to the prior state.
On OpenSUSE you can manage this either graphically with YaST or via the command line with Zypper. This guide will cover Zypper, since it’s both the most direct and the most universal.
To start, search through your Zypper history with
cat /var/log/zypp/history | grep package_name
Once you’ve found the version that you want to revert to, install it.
sudo zypper -in -f package_name-version
Rolling back packages to an earlier version on Arch Linux is very simple, providing you don’t clear Pacman’s cache too frequently. Pacman, Arch’s package manager, stores every package that you install in a designated cache folder.
As with most things in Arch, this is designed for simplicity. The Arch developers understand that bugs are bound to slip through occasionally in a distribution as fast-paced as Arch, so they’ve made the rollback process as uncomplicated as possible.
Check which versions are available by listing the contents of “/var/cache/pacman/pkg/.” You’ll have an easier time if you search with
ls /var/cache/pacman/pkg/ | grep package_name
Once you’ve located it, install it with Pacman.
sudo pacman -U /var/cache/pacman/pkg/package_name-version.pkg.tar.xz
Pacman will automatically install the older version over the current package.
That’s all you need to do. Follow the process that fits your distribution, and you’ll be able to return your system to a previous, and hopefully less problematic, version of a package. You should also keep in mind that these methods all go against the regular flow of your distribution, so they may not always work. They’re a great first step, and something you should always try, tough.
Our latest tutorials delivered straight to your inbox