Using Synaptic Package Manager GUI App
Synaptic package manager is a graphical frontend to the apt package manager. It has almost full feature parity with its command line counterpart, while being pretty easy to use and straightforward. It also provides numerous filters for clean categorization of packages.
It is possible to freeze packages using Synaptic package manager. To install it in Ubuntu, run the command below:
Many Ubuntu users prefer to downgrade a package to a specific version before locking it. So, let’s first look at the downgrading process. A package can be downgraded to an earlier version if multiple builds of it exists on Ubuntu’s server. Some packages never receive updates throughout the support period of a specific Ubuntu version, so not all packages can be downgraded.
The figure below shows how to downgrade Firefox to an earlier version using Synaptic package manager. After launching Synaptic form application launcher, search for your desired package name and click on it to highlight it. Click on “Package” > “Force Version…” to begin the downgrading process. As stated earlier, not all packages support downgrading, so “Force Version…” option may be greyed out in these cases.
In the next window, select the older version of Firefox to downgrade it. Click on “Apply” button on the toolbar to initiate the downgrading process. You will see a new window popup that will ask for your confirmation, just follow the on-screen instructions to finish the downgrading process.
Now to actually lock a package, you have to follow a similar process as above. Click on your desired package and then go to “Package” dropdown menu. Click on “Lock Version” to prevent it from updating in future. Unlike downgrading, any package can be locked.
A locked package will have a checkbox in front of it with a small lock icon to indicate that it has been frozen.
To see all locked packages on your system, click on “Status” > “Pinned”.
The same process can be followed to unlock a package. You just have to click on “Lock Version” again.
Using Apt Package Manager
Apt package manager is the default package manager shipped with Ubuntu. If you are using Ubuntu, chances are that you may have already used it to run some package management commands.
Using apt, you can run the command mentioned below to see all packages that are locked or being held.
To lock a specific package, run a command in the following format:
So, to lock firefox package, the command would be:
If you again run “showhold” command mentioned above, firefox will be listed in terminal as a locked package.
To unhold a package, run a command in the following format:
For the firefox package locked using the command above, the appropriate command to unhold would be:
Using Aptitude Package Manager
Aptitude package manager is a newer package manager based on apt. It is simple to use and provides some handy extra options over apt, along with a terminal based frontend to easily manage packages.
To install Aptitude in Ubuntu, you have to run the command below:
The aptitude package manager has similar command pattern to apt. Command to hold a package is (replace package-name):
Command to unhold a package is (replace package-name):
To see all held packages using the aptitude package manager, run command:
Dpkg is a simple utility to manage installation and uninstallation of debian software packages. Just like apt package manager, it can be used to lock packages with some straightforward commands.
To lock a package using dpkg, run a command in the following format (replace package-name):
To unlock a package, run command (replace package-name):
To see all packages locked by dpkg, run command:
To check if a particular package has been locked or not, run command (replace package-name):
These are a few methods that you can use to lock packages in Ubuntu. Unless you really want a specific version of package, locking and downgrading should be avoided, especially for packages that need regular security updates like web browsers and the Linux kernel.