How To Keep A Package From Updating In Ubuntu, Debian Or Linux Mint [APT]
There are multiple ways of preventing a package from updating in Debian, Ubuntu, Linux Mint, elementary OS and other Debian/Ubuntu-based Linux distributions. This article presents 3 ways of excluding repository packages from being upgraded.
Why prevent a package from being updated? Let's say you install a package that's older than the version available in Debian, Ubuntu or Linux Mint repositories, or you know some update is causing issues, and you want to upgrade all packages minus one (or two, three...).
Here's an example. I'm using Chromium browser with hardware acceleration patches from the Saiarcot895-dev PPA, in Ubuntu 18.10. To get hardware acceleration to work with Nvidia drivers, a patched vdpau-va-driver package is needed, and this is not yet available in this PPA for the latest Ubuntu 18.10. Luckily, the Ubuntu 18.04 package can be installed in Ubuntu 18.10, but any upgrade through "apt upgrade" or using the Software Updater will upgrade this package, which I don't want. So in this case, holding this package from upgrades would allow me to upgrade all other packages without having to worry about it.
It should be noted that preventing a package from future upgrades may cause issues in some situations, if the package you're holding is used as a dependency for another package that can be upgraded. So try not to prevent too many packages from upgrades, especially libraries.
From the same series: How To Search Available Packages From Command Line In Debian, Ubuntu Or Linux Mint [APT]
Here are 3 ways of preventing a package from updating in Debian, Ubuntu, Linux Mint.
1. Prevent package updates using a GUI: Synaptic Package Manager
Synaptic Package Manager, a Gtk graphical package management program for apt, can lock packages which prevents them from being updated.
It's important to note that using Synaptic to lock packages won't keep them from being updated from the command line - running
You can install Synaptic Package Manager using this command:
To prevent a package from updating using Synaptic, search for it, select the package and from the Synaptic menu click
In the same way you can unlock the package too.
To see all locked packages in Synaptic, click
2. Keep a package from updating using
Holding packages from updating with apt-mark should prevent them from updating using Ubuntu's Software Updater, as well as command line upgrades (
You can hold a package from future upgrades (and from being automatically removed) with
Replacing
You can check which packages are marked as
To remove a hold (so the package can be updated), use:
For both
3. Prevent package updates with
A while back there were some graphical package managers that ignored the apt-mark hold status. I'm not sure if that's still the case, but just to be safe (and in case you're using an old Debian / Ubuntu / Linux Mint version), here's another way of preventing package updates in Ubuntu, Linux Mint or Debian: dpkg.
To prevent a package from upgrades using dpkg, use:
Replace
You can see all package holds using this command:
To remove the hold (allow the package to be upgraded), use:
Unlike
Why prevent a package from being updated? Let's say you install a package that's older than the version available in Debian, Ubuntu or Linux Mint repositories, or you know some update is causing issues, and you want to upgrade all packages minus one (or two, three...).
Here's an example. I'm using Chromium browser with hardware acceleration patches from the Saiarcot895-dev PPA, in Ubuntu 18.10. To get hardware acceleration to work with Nvidia drivers, a patched vdpau-va-driver package is needed, and this is not yet available in this PPA for the latest Ubuntu 18.10. Luckily, the Ubuntu 18.04 package can be installed in Ubuntu 18.10, but any upgrade through "apt upgrade" or using the Software Updater will upgrade this package, which I don't want. So in this case, holding this package from upgrades would allow me to upgrade all other packages without having to worry about it.
It should be noted that preventing a package from future upgrades may cause issues in some situations, if the package you're holding is used as a dependency for another package that can be upgraded. So try not to prevent too many packages from upgrades, especially libraries.
From the same series: How To Search Available Packages From Command Line In Debian, Ubuntu Or Linux Mint [APT]
Here are 3 ways of preventing a package from updating in Debian, Ubuntu, Linux Mint.
1. Prevent package updates using a GUI: Synaptic Package Manager
Synaptic Package Manager, a Gtk graphical package management program for apt, can lock packages which prevents them from being updated.
It's important to note that using Synaptic to lock packages won't keep them from being updated from the command line - running
apt upgrade
or apt-get upgrade
will still upgrade a package locked in Synaptic. Locking packages in Synaptic will prevent package upgrades using Ubuntu's Software Updater app, and possibly other graphical package managers. It will not prevent updating packages using the Linux Mint Update Manager application though. As a result, I recommend using apt-mark
or dpkg
(see below) to keep packages from updating.You can install Synaptic Package Manager using this command:
sudo apt install synaptic
To prevent a package from updating using Synaptic, search for it, select the package and from the Synaptic menu click
Package -> Lock Version
:In the same way you can unlock the package too.
To see all locked packages in Synaptic, click
Status
in the bottom left-hand side, then click on Pinned
above the Status
section:2. Keep a package from updating using
apt-mark
Holding packages from updating with apt-mark should prevent them from updating using Ubuntu's Software Updater, as well as command line upgrades (
apt upgrade
/ apt-get upgrade
).You can hold a package from future upgrades (and from being automatically removed) with
apt-mark
by using this command:sudo apt-mark hold PACKAGE
Replacing
PACKAGE
with the package you want to hold from updating.You can check which packages are marked as
hold
(so they won't be updated) by using:apt-mark showhold
To remove a hold (so the package can be updated), use:
sudo apt-mark unhold PACKAGE
For both
hold
and unhold
you can specify multiple packages, just like when installing software with apt
(separate the packages by a space).3. Prevent package updates with
dpkg
A while back there were some graphical package managers that ignored the apt-mark hold status. I'm not sure if that's still the case, but just to be safe (and in case you're using an old Debian / Ubuntu / Linux Mint version), here's another way of preventing package updates in Ubuntu, Linux Mint or Debian: dpkg.
To prevent a package from upgrades using dpkg, use:
echo "PACKAGE hold" | sudo dpkg --set-selections
Replace
PACKAGE
with the package you want to hold from updating.You can see all package holds using this command:
dpkg --get-selections | grep hold
To remove the hold (allow the package to be upgraded), use:
echo "PACKAGE install" | sudo dpkg --set-selections
Unlike
apt-mark
, this solution doesn't allow specifying multiple packages at once.