Ubuntu package manager keeps the packages updated by upgrading them to the latest version. But sometimes due to the upgrade, programs do not work smoothly because of bugs or compatibility issues in the new version as compared to the previous versions. We can overcome this issue by downgrading the installed packages to their earlier versions where they were working fine and then locking down them at a particular version to prevent them from being updated automatically in the future.
In this article, we will see how to downgrade an installed package on Ubuntu. There are two different ways using which we can use to downgrade an installed package to its earlier version:
- Using Synaptic Package Manager
- Using Terminal
We will see how to use both of these ways to downgrade Firefox application in Ubuntu. However, you can follow this same procedure for downgrading other applications too.
We will use Ubuntu 18.04 LTS for describing the procedure mentioned in this article.
Downgrade packages using Synaptic Package Manager
The Synaptic package manager is a graphical-based package management application that is more powerful than Ubuntu’s software center. Using it, you can install, upgrade, downgrade and remove packages, search for packages using filers, lock packages and much more using its user-friendly GUI interface.
Step 1: It is not installed by default in Ubuntu 18.04 LTS, so we will need to first install synaptic package manager. For that, open the Terminal by using Ctrl+Alt+T key shortcut. Then enter the following command:
$ sudo apt install synaptic
Wait for a while until the installation is completed.
Step 2: Once the installation is completed, run the following command in Terminal to launch the Synaptic package manager.
$ sudo synaptic
It will prompt for the password. Enter the password to authenticate it.
Step 3: In the main application window, search for the package you to want to downgrade. For that, click on the Search button from the toolbar. In the search box, type the package name and click on Search. We are going to downgrade Firefox application, so we will type firefox in the search bar.
Step 4: When the search result appears, select the Firefox application. You will see the current and the latest available versions of the Firefox application. Then from the menu bar, click on Package, and then select Force Version.
A dialog box will appear that will allow you to choose the version of the package you want to downgrade to. Select the required version from the drop-down menu and click Force Version button.
Step 5: Then from the toolbar, click on Apply to save the changes.
A confirmation dialog box will appear, click on Apply to confirm.
Now it will start downloading the older package.
Once the download is finished, you will note that the installed version is now 59.0.2+build1-0ubuntu1 in the Synaptic application window that has downgraded from 65.0+build2-0ubuntu0.18.04.1.
Step 6: After downgrading the Firefox package, you can also prevent the package from being updated automatically by locking it at a specific version. Select the downgraded Firefox application, and from the top menu bar, click on Package. Then select Lock Version. Next time when you upgrade your packages, this locked package will not be upgraded.
Once done with the process, you can also view the current version of the Firefox by using the Firefox menu. Click on the Firefox menu button on the right side of its window, and then click on Help as shown in below screenshot.
Then from the sub-menu, select About Firefox.
About Mozilla Firefox window will appear. You can see here the version number.
Unlock Packages in Synaptic
To unlock a package in Synaptic, search for the package in the package list, the easiest way is to search here by status ‘pinned’. Then click on the “Package” in the upper menu and de-select “Lock version” in the menu.
Downgrade packages using Ubuntu Terminal
We can also use the Terminal application in Ubuntu for downgrading packages. Press Ctrl+Alt+T to launch the Terminal.
Step 1: To list the available version of a specific package in the repositories, run the following command in Terminal:
$ sudo apt-cache showpkg package-name
For instance, to downgrade the Mozilla Firefox application to the older version, we will use the following command. It will search the repository for older versions of Firefox:
$ sudo apt-cache showpkg firefox
Step 2: To install an older version of any package, run the following command in Terminal:
$ sudo apt-get install packagename=version
From the above results, we can see that the available older version of Firefox is 59.0.2+build1-0ubuntu1. To downgrade Firefox application to this version, run the following command in Terminal. It will simply install the older version of Firefox using apt-get command.
$ sudo apt-get install firefox=59.0.2+build1-0ubuntu1
When prompted for confirmation, press y to confirm.
Step 3: Once the above process is finished, you can check the version of the Firefox to verify. From the below screenshot, you can see that it has successfully downgraded to version 59.02.
Step 4: Similar to Synaptic package manager, in the Terminal, you can also hold or lock the packages from being updated or upgraded automatically. Run the following command in Terminal to lock the package:
$ sudo apt-mark hold firefox
However, this method only prevents the package from being upgraded automatically. It cannot prevent or stop the package from manual up-gradation.
So that is all you need to do in order to downgrade packages on Ubuntu. Because of this, now you are able to return your packages to a previous state where they were working fine and lock them out from future upgrades.