How To Downgrade Packages To A Specific Version With Apt In Debian, Ubuntu Or Linux Mint

This article explains how to downgrade a package to a specific version using apt, in Debian, Ubuntu or Linux Mint (from the command line).

Sometimes you may encounter issues with a recently upgraded package, and you want to downgrade it. To be able to downgrade a package in Debian, Ubuntu or Linux Mint (and other Debian/Ubuntu-based Linux distributions), the package version to which you want to downgrade must be available in a repository.

From the same series:


To downgrade a package to a specific version, you'll need to append =version after the package name in the installation command, with version being the version to which you want to downgrade the package:

sudo apt install <package>=<version>

Example 1.

Let's look at a simple example. I currently have Firefox 65 installed in Ubuntu 18.10, and I want to downgrade it using apt. The first thing to do is to look at the available versions, by running apt policy firefox (apt-cache policy works as well):

$ apt policy firefox
firefox:
  Installed: 65.0+build2-0ubuntu0.18.10.1
  Candidate: 65.0+build2-0ubuntu0.18.10.1
  Version table:
 *** 65.0+build2-0ubuntu0.18.10.1 500
        500 http://security.ubuntu.com/ubuntu cosmic-security/main amd64 Packages
        500 http://archive.ubuntu.com/ubuntu cosmic-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     63.0+build1-0ubuntu1 500
        500 http://archive.ubuntu.com/ubuntu cosmic/main amd64 Packages

This apt command shows that the Firefox version installed on my system is 65.0+build2-0ubuntu0.18.10.1, and it's available in the cosmic-security and cosmic-updates repositories. There is an older version, 63.0+build1-0ubuntu1, available in the main repository, so Firefox can be downgraded to this version.

To downgrade Firefox from the installed 65.0+build2-0ubuntu0.18.10.1 version, to the 63.0+build1-0ubuntu1 version from the main repository, the command would be:

sudo apt install firefox=63.0+build1-0ubuntu1

This command downgrades Firefox without having to downgrade any other packages, because Firefox doesn't depend on any strict package versions:

$ sudo apt install firefox=63.0+build1-0ubuntu1
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be DOWNGRADED:
  firefox
0 upgraded, 0 newly installed, 1 downgraded, 0 to remove and 51 not upgraded.
Need to get 46.1 MB of archives.
After this operation, 4,243 kB disk space will be freed.
Do you want to continue? [Y/n]

There are cases in which you must resolve some dependencies to be able to downgrade the package though, and we'll look at an example like that below.

Example 2.

Let's look at a more complicated example - a package that can't be directly downgraded using apt without also downgrading some of its dependencies.

$ apt policy chromium-browser
chromium-browser:
  Installed: 72.0.3626.81-0ubuntu1~ppa2~18.10.1
  Candidate: 72.0.3626.81-0ubuntu1~ppa2~18.10.1
  Version table:
 *** 72.0.3626.81-0ubuntu1~ppa2~18.10.1 500
        500 http://ppa.launchpad.net/saiarcot895/chromium-beta/ubuntu cosmic/main amd64 Packages
        100 /var/lib/dpkg/status
     71.0.3578.98-0ubuntu0.18.10.1 500
        500 http://security.ubuntu.com/ubuntu cosmic-security/universe amd64 Packages
        500 http://archive.ubuntu.com/ubuntu cosmic-updates/universe amd64 Packages
     69.0.3497.100-0ubuntu1 500
        500 http://archive.ubuntu.com/ubuntu cosmic/universe amd64 Packages

The apt policy command above shows that I currently have Chromium browser beta (version 72) installed from the Saiarcot Chromium Beta PPA, with two older versions being available in the Ubuntu security/updates and main repositories.

Let's try to downgrade chromium browser from version 72.0.3626.81-0ubuntu1~ppa2~18.10.1 to version 71.0.3578.98-0ubuntu0.18.10.1 (from the security/updates repositories) using apt and see what happens:

$ sudo apt install chromium-browser=71.0.3578.98-0ubuntu0.18.10.1
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 chromium-browser : Depends: chromium-codecs-ffmpeg-extra (= 71.0.3578.98-0ubuntu0.18.10.1) but 72.0.3626.81-0ubuntu1~ppa2~18.10.1 is to be installed or
                             chromium-codecs-ffmpeg (= 71.0.3578.98-0ubuntu0.18.10.1) but it is not going to be installed
                    Recommends: chromium-browser-l10n but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Downgrading Chromium browser doesn't work because it depends on chromium-codecs-ffmpeg-extra or chromium-codecs-ffmpeg, with the exact same version as the chromium-browser package itself. In this case, let's also downgrade the chromium-codecs-ffmpeg-extra package to the same version:

$ sudo apt install chromium-browser=71.0.3578.98-0ubuntu0.18.10.1 chromium-codecs-ffmpeg-extra=71.0.3578.98-0ubuntu0.18.10.1
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  webaccounts-chromium-extension unity-chromium-extension adobe-flashplugin
Recommended packages:
  chromium-browser-l10n
The following packages will be REMOVED:
  chromium-browser-l10n chromium-chromedriver
The following packages will be DOWNGRADED:
  chromium-browser chromium-codecs-ffmpeg-extra
0 upgraded, 0 newly installed, 2 downgraded, 2 to remove and 51 not upgraded.
Need to get 58.8 MB of archives.
After this operation, 61.5 MB disk space will be freed.
Do you want to continue? [Y/n]

The apt downgrade command output shows that chromium-browser can now be downgraded, but the command wants to remove 2 packages. Those are recommended packages that were automatically installed when chromium-browser was installed (and they too need to be the exact same version as the chromium-browser package), and while they are not required by chromium-browser, you may still need them. So it's a good idea to downgrade those as well, so they are not removed.

In this case, the apt downgrade command becomes:

sudo apt install chromium-browser=71.0.3578.98-0ubuntu0.18.10.1 chromium-codecs-ffmpeg-extra=71.0.3578.98-0ubuntu0.18.10.1 chromium-browser-l10n=71.0.3578.98-0ubuntu0.18.10.1 chromium-chromedriver=71.0.3578.98-0ubuntu0.18.10.1

Let's look at what happens when we use it:

$ sudo apt install chromium-browser=71.0.3578.98-0ubuntu0.18.10.1 chromium-codecs-ffmpeg-extra=71.0.3578.98-0ubuntu0.18.10.1 chromium-browser-l10n=71.0.3578.98-0ubuntu0.18.10.1 chromium-chromedriver=71.0.3578.98-0ubuntu0.18.10.1
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  webaccounts-chromium-extension unity-chromium-extension adobe-flashplugin
The following packages will be DOWNGRADED:
  chromium-browser chromium-browser-l10n chromium-chromedriver chromium-codecs-ffmpeg-extra
0 upgraded, 0 newly installed, 4 downgraded, 0 to remove and 51 not upgraded.
Need to get 64.9 MB of archives.
After this operation, 35.8 MB disk space will be freed.
Do you want to continue? [Y/n]

As you can see, the downgrade can be performed, and no packages are about to be removed. Since it all looks good now, we can proceed with the downgrade.