Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

I used to do something similar with yum on CentOS. I think there was a --enable-repo and --disable-repo param.

Is there something that exists for apt-get install <some pkg> that will restrict to /etc/apt/sources.list.d/<somefile>?

share|improve this question

You can do that by pinning the release using /etc/apt/preferences. The man page is apt_preferences. Format is as follows:

 Package: *
 Pin: release o=Debian,a=testing
 Pin-Priority: 900
share|improve this answer

I don't believe you can do that quickly and easily without a wrapper around apt-get to juggle the sources manually.

One option however is to suffix the package you wish to install with the version number required, which will likely be different in each source.


apt-get install cowsay=3.03-9.2
share|improve this answer
You can also check the versions and what would be installed using apt-cache policy cowsay - then use the resulting version, etc. to specify the package specifically. – Mei Jun 30 '11 at 13:39

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.