Introduction
If you need to keep a specific version of a deb package from updating on Debian-derived Linux distributions, there are several command-line tools to lock or hold back package versions.
This guide uses the dpkg command, though similar operations can be performed using apt or dselect.
On hold
To put a package on hold:
# echo "<package-name> hold" | dpkg --set-selections
After executing this command, the package will remain at its current installed version even when general system updates are performed.
Remove hold
To remove the hold status and allow updates again:
# echo "<package-name> install" | dpkg --set-selections
After this command, the package will update normally alongside other packages.
Show status
1. Show status of all packages
# dpkg --get-selections
7zip install
accountsservice install
acl install
adduser install
adwaita-icon-theme install
aglfn install
alsa-topology-conf install
alsa-ucm-conf install
alsa-utils install
...
2. Show status of a single package
# dpkg --get-selections <package-name>
# dpkg --get-selections zip
zip install
Show packages currently on hold
# dpkg --get-selections | grep "\<hold$"
# dpkg --get-selections | grep "\<hold$"
lifeograph hold