Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a package I do not want to be installed even if another needs it.

Is there any way to "blacklist" a package from being installed even as a dependency of another?

Can I overcome the fact that it is a dependency and still be able to upgrade my system?

I am thinking in particular about the messaging indicator from Unity. If I remove it and add Unity again for some reason, I dont want the applet installed again. How can I prevent it from being installed? (or the global menu, java versions removing my custom installed one, etc... you get the idea).

share|improve this question
Is it available by apt-get command? –  Vidyadhar Jan 27 '12 at 19:16
Yes, I am talking about apt as tagged on the question. –  Bruno Pereira Jan 27 '12 at 19:19
In my case I installed texlive from the TUG website so I would like to block all texlive related packages from Ubuntu. –  Gerhard Burger Jan 30 '13 at 16:16
bruno: askubuntu.com/questions/18654/… ;) see AbrahamVanHelpsing´s answer. –  Rinzwind Jan 30 '13 at 19:48

2 Answers 2

  • Is there any way to "blacklist" a package from being installed even as a dependency of another?

To prevent apt from installing a package foo, add a stanza for that package to the file /etc/apt/preferences which looks like the following.

Package: foo
Pin: release *
Pin-Priority: -1

This will prevent apt from installing foo and will also prevent apt from installing anything that Depends on foo.

The next closest thing I can think of is to put a hold on foo at its current version which prevents foo from being upgraded (unless dpkg is given the --force-hold option or unless apt overrides the hold). To put a hold on package foo, do the following.

echo foo hold | sudo dpkg --set-selections
  • Can I overcome the fact that it is a dependency and still be able to upgrade my system?

You can install individual packages despite dependency violations using dpkg --force-depends. You won't be able to use apt to do this unless you apt-get source the package that Depends on foo and rebuild it without the dependency on foo.

share|improve this answer
Thanks, I guess this is as good as it gets... if I hold the package texlive-base and try to install latexmk I get The following packages have unmet dependencies: latexmk : Depends: texlive-latex-base but it is not going to be installed which is of course what I want. But if I hold latexmk and do sudo apt-get install latexmk I will get The following held packages will be changed: latexmk, as it turns out this actually removes the hold (well it least I get a warning). –  Gerhard Burger Feb 4 '13 at 6:39
In an edit I just explained another way of preventing the installation of a package, using a stanza in /etc/apt/preferences. This has no effect on dpkg, of course. And it is still the case that if you blacklist a package you won't be able to use apt to install anything that Depends on it. –  jdthood Feb 6 '13 at 19:24

If a package needs (depends on) another package, then it should not work properly without it. If it can, it is a bug, it should be a recommend and not a depend.

To avoid to install a dependency:

  1. download the required packages:

    sudo apt-get --download-only install pkg-name
  2. remove unwanted packages

    sudo rm /var/cache/apt/archive/bad-pkg_*.deb
  3. install all other packages

    sudo apt-get --no-download --ignore-missing install pkg-name

On the other side, to install a package without recommends:

sudo apt-get --no-install-recommends install pkg-name
share|improve this answer
@BrunoPereira: see updated answer. –  enzotib Jan 27 '12 at 20:59
@BrunoPereira: I would like to have some feedback from you. –  enzotib Jan 28 '12 at 17:48
When you lock a package version does also lock a non installed package? I think (I'm sure) your solution would work but would really not rather use since in a update example it would still install the package, no? –  Bruno Pereira Jan 28 '12 at 17:56
Yes, in a next install apt would try to resore what it think is missing. –  enzotib Jan 28 '12 at 18:10

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.