Monday, 10 August 2020

Ubuntu - How to prevent updating of a specific package?


There are couple of ways to prevent packages getting updated by default.

1. apt

2. dpkg

3. aptitude

4. dselect


1. apt

Using hold and unhold you can stop packages getting updated

hold (To stop)

sudo apt-mark hold <package>


ex:- sudo apt-mark hold kubeadm kubelet kubectl kubelet

unhold (To Allow)

sudo apt-mark unhold <package>

ex:- sudo apt-mark unhold kubeadm kubelet kubectl kubelet

To view all packages on hold

sudo apt-mark showhold


2. dpkg

To hold the Package

echo "<package> hold" | sudo dpkg --set-selections

To remove the hold

echo "<package> install" | sudo dpkg --set-selections

To display status of a single package

dpkg --get-selections | grep "<package>"

To display status of all packages

dpkg --get-selections


3. aptitude

To hold a package:

sudo aptitude hold <package>

To remove the hold

sudo aptitude unhold <package>


Tricks and Tips