I am running Ubuntu 14.04 and have let it get quite out of date with packages that need updating.

There are a couple of packages I don't want to upgrade like tomcat, php etc.. but I am not sure how I can run a blanket apt-get upgrade to upgrade everything except those packages. Most of the documentation and suggestions I can find only explain how to update specific packages, not the other way around..?



What you want is "package pinning" -- essentially, telling apt, "I want to keep this package at this version". For a simple single-package pin, add this to /etc/apt/preferences (or in a new file in /etc/apt/preferences.d):

Package: tomcat8
Pin: version 8.0.14-1
Pin-Priority: 1001

Specify the package name you want, and the version you want to pin it to, and make sure the Pin-Priority is over 1000. Then the package will basically never, ever move from its current version.

You can do trickier things, like pinning to a release (trusty rather than trusty-updates, for example), selecting lots of packages with a glob pattern, and only letting packages update if they're security updates. See apt_preferences(5) for all the gory details.

  • In /etc/apt I don't seem to have a "preferences" file to edit. I do however have a (preferences.d) folder. If I put a file in there what do I call it? Thanks – Pelly Nov 24 '15 at 5:29
  • Per apt_preferences(5): "Note that the files in the /etc/apt/preferences.d directory are parsed in alphanumeric ascending order and need to obey the following naming convention: The files have either no or "pref" as filename extension and only contain alphanumeric, hyphen (-), underscore (_) and period (.) characters. Otherwise APT will print a notice that it has ignored a file, unless that file matches a pattern in the Dir::Ignore-Files-Silently configuration list - in which case it will be silently ignored." – womble Nov 24 '15 at 5:31

To hold a package:

In short: sudo apt-mark hold <package>


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

To unhold a package:

In short: sudo apt-mark unhold <package>


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

Ref: Exclude packages from apt-get upgrade

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.