How to prevent software packages from being updated in Ubuntu, Debian or Linux Mint [APT]

There are multiple ways to prevent packages from being updated in Debian, Ubuntu, Linux Mint, basic OS, and other Debian / Ubuntu-based Linux distributions. This article describes three ways to exclude upgrading repository software packages.
Why should package updates be blocked? Suppose the version of the package you installed is earlier than the version available in the Debian, Ubuntu or Linux Mint repository, or you know that some updates will cause problems, and you want to subtract all packages (one or two, three) …).
This is an example. I am using the hardware acceleration patch from Saiarcot895-dev PPA (in Ubuntu 18.10) in the Chromium browser. In order to use hardware acceleration with the Nvidia driver, a patched vdpau-va-driver package is required, and the latest Ubuntu 18.10 is not yet available in this PPA. Fortunately, 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, I don’t want to do this. Therefore, in this case, keeping this package from the upgrade will allow me to upgrade all other packages without worrying.
Please note that if the package you hold is used as a dependency of another package that can be upgraded, in some cases, preventing the package from being upgraded in the future may cause problems. Therefore, please try not to prevent too many software package upgrades, especially libraries. In the same series: How to search for available packages from the command line in Debian, Ubuntu or Linux Mint [APT]
These are three ways to prevent software packages from being updated in Debian, Ubuntu, Linux Mint.1. Using GUI to prevent package updates: Synaptic Package Manager
Synaptic Package Manager is a Gtk graphical package management program for apt. It can lock packages to prevent them from being updated. It is important to note that using Synaptic lock packages will not prevent them from being updated from the command line-run apt upgrade Or apt-get upgrade Packages locked in Synaptic will still be upgraded. Locking packages in Synaptic will prevent package upgrades using Ubuntu’s Software Updater application and other graphical package managers. However, it does not prevent the software package from being updated with the Linux Mint Update Manager application. Therefore, I recommend using apt-mark Or dpkg (See below) to prevent software package updates.
You can install Synaptic Package Manager using the following command:

sudo apt install synaptic

To prevent a package from using Synaptic updates, search for it, select the package, and click from the Synaptic menu Package -> Lock Version:

Similarly, you can also unlock the package.
To view all locked packages in Synaptic, click Status In the lower left corner and click Pinned the above Status section:Synapse display lock (fixed) package2. Prevent updates to software packages apt-mark
Prohibit the use of apt-mark to update software packages, which will prevent them from using Ubuntu’s Software Updater and command line upgrades to update (apt upgrade / apt-get upgrade).
You can keep the software package in the following ways to prevent future upgrades (and it will not be automatically deleted) apt-mark By using the following command:

sudo apt-mark hold PACKAGE

Replace PACKAGE Update with the software package you want to keep.
You can check which packages are marked as hold (So ​​that they will not be updated), the method is:

apt-mark showhold

To delete the reservation (so that the package can be updated), use:

sudo apt-mark unhold PACKAGE

For each other hold with unhold You can specify multiple packages just like using apt (Separate packages with spaces) 3. Block package updates dpkg
Not long ago, some graphical package managers ignored the apt-mark retention status. I’m not sure if this is still the case, but for security reasons (in case you use an old Debian / Ubuntu / Linux Mint version), this is another way to prevent package updates in Ubuntu, Linux Mint or Debian: dpkg.
To prevent software packages from being upgraded using dpkg, use:

echo "PACKAGE hold" | sudo dpkg --set-selections

Replace PACKAGE Update with the software package you want to keep.
You can use the following command to view all package security:

dpkg --get-selections | grep hold

To delete the reservation (allowing software package upgrades), use:

echo "PACKAGE install" | sudo dpkg --set-selections

Unlike apt-mark, This solution does not allow specifying multiple packages at once.

Source

Sidebar