How to exclude a package from being updated on Linux

Image by Marc Falardeau – CC BY 2.0

Sometimes you prefer not to update a specific package in Linux. This may be because you don’t want to upgrade to a new version with new features but no security updates. Or maybe because upgrading requires a service restart that you want to avoid just yet. This was the case for me recently when a new version of Docker came up and upgrading would have restarted the docker daemon and stopped the running containers.

It is possible to exclude a package from being updated. On Linux RPM systems (RedHat, CentOS, Fedora, etc.) this is the command to install all updates but exclude a specific package (say docker):

sudo yum update --exclude=docker

On Debian-like systems (Debian, Ubuntu, Mint, etc.) it is slightly more convoluted because you need to hold a package first and then upgrade the system

sudo apt-mark hold docker && sudo apt-get upgrade

and remember to remove the hold when you’re ready to upgrade that package too

sudo apt-mark unhold docker



One thought on “How to exclude a package from being updated on Linux”

Leave a Reply

Your email address will not be published. Required fields are marked *