TIL: How to prevent a package from updating on ubuntu

1 minute read Published:

Short howto: package pinning on ubuntu

Sometimes you need to upgrade a server, but you also need to prevent apt from upgrading a specific package (eg. your node.js version). Many package-managers support this scenario under names like “version pinning” or “package holding”. This is how you prevent apt from upgrading a single package:

Dependencies

  • Ubuntu 12.04 or newer
  • apt

Pin a package to prevent it from being upgraded

sudo apt-mark hold $PACKAGE_NAME

Unpin a package to allow it being upgraded again

sudo apt-mark unhold $PACKAGE_NAME