I have a problem with a program crashing, and I suspect that only the latest version of the package has this problem, so I wish to block this particular version from ever being installed – but I still want to be able to upgrade to future versions.

I think I've read (somewhere, at some point) that the apt system allows for this, but now that I look for it I seem unable to find it.

How would I go about doing this?

P.S. I'm intentionally vague about which package I'm having problems with, as I want to understand this feature of Apt (if indeed it exists), and do not want suggestions specific to the program I'm having problems with.


Edit the /etc/apt/preferences file and add:

Package: unzip
Pin: version 2.7
Pin-Priority: 100

Package: unzip
Pin: version 3*
Pin-Priority: 1000

This will keep the package on 2.7, skip 2.8, 2.9 and upgrade to 3* when available.

Note that this is an unnatural way of not upgrading to an unstable package version. A better (and the recommended way) is to hold the package till the issues are resolved:


$ echo "package hold" | sudo dpkg --set-selections


$ sudo aptitude hold package_name 
| improve this answer | |
  • To undo the hold with dpkg: echo "package_name install" | sudo dpkg --set-selections or with aptitude: aptitude unhold package_name – Paul Tobias Dec 28 '17 at 2:34

aptitude allows this with the forbid-version option.

Select the version of the package in the UI and press 'F'

Alternatively you could do it via the command line interface, see manpage:

           Forbid a package from being upgraded to a particular version, while allowing automatic upgrades to future versions. This is useful for example to avoid a known broken version of a package,
           without having to set and clear manual holds.

           By default, aptitude will select the forbidden version to be the one which the package would normally be upgraded (the candidate version). This may be overridden by appending „=<version>“ to the
           package name: for instance, „aptitude forbid-version vim=1.2.3.broken-4“.

           To revert the action, „aptitude install <package>“ will remove the ban. To remove the forbidden version without installing the candidate version, the current version should be appended: „install

Please note: This forbidden version is only honoured by aptitude. apt-get or other package managers will upgrade the package if run.

| improve this answer | |
  • This information is stored in /var/lib/aptitude/pkgstates, look for ForbidVer:. To verify which version(s) are forbidden use aptitude versions packagename, the forbidden versions will have a capital F in the first column. – Paul Tobias Aug 31 '17 at 5:22

You can use 'apt-get install package-version' to install a specific version of this package.

You can prevent to update this version with a specific configuration of /etc/apt/preferences. See 3.10 section at:


You can do it too with apt-mark command. See "hold" option at:

Ubuntu Manpages

| improve this answer | |

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.