Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In short, I want to be able to set package abc so that:

  1. apt-get remove abc should fail.
  2. apt-get purge abc should fail.
  3. apt-get upgrade abc should work.

If the package dependencies change so that abc should be uninstalled during an dist-upgrade I am happy to being forced to do something and then dist-upgrade again.

share|improve this question
I created an essential metapackage that depends on abc, but it was removed anyway... I think you have to recompile the abc setting Essential: yes and Priority: required in debian/control – Teresa e Junior Jan 22 '12 at 9:51
@TeresaeJunior Strange, an essential package def depending on abc should have worked. Was def removed? Does it help if you make def Priority: required? – Gilles Jan 22 '12 at 23:42
@Gilles Exactly, I set both Essential: yes and Priority: required and it was removed with no warnings. I created this small script to make the package, if you want to have a look: paste.org/44184 – Teresa e Junior Jan 23 '12 at 6:49
I see that Essential: yes was ignored, so equivs is not sufficient for that... Maybe if the package is created with debuild, I'll try. – Teresa e Junior Jan 23 '12 at 6:54

Not really anything to 'pin' a package down to be able to prevent removal, but allow upgrading.

You can hammer a spike into a package, can't be deleted, purged, upgraded, licked, anything...

But it's a wee bit more complicated than most things.

For example, we wish to pin firefox down: (you'd use the proper full name of the package, of course)

echo firefox hold | dpkg --set-selections

which would then make 'firefox' immortal. BUT, it cannot be upgraded in this state either.

To remove the hold status is a bit easier, but it's kind of a sweeping gesture:

dpkg --clear-selections

removes the HOLD status from EVERYTHING! So if you wanted to hold a few packages, you'd best keep a list to reapply later

It's actually quite pleasant and easy to perform using aptitude or synaptics, as they have menu options to hold/unhold a package, taking care of all the bookkeeping behind the scenes for you. I'd recommend using one of those (or any of a myriad other package managers you might encounter)

With Aptitude, command line usage is possible too:

aptitude hold <package>
aptitude unhold <package>

Remember though, you'll need to 'unhold' something if want it to upgrade. Although if you use the GUI side of Aptitude, it should tell you if something that's held is upgradable

share|improve this answer
apt-get will happily uninstall a held package. – bahamat Aug 20 '12 at 20:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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