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 want to restrict the packages installable from a repo, eg restrict some packages to the main Ubuntu repos, even if they are available from launchpad or some other third party repos, something like pinning some packages to certain repository.

Normally the repository last added repo takes over all the packages which were available in other earlier repos.

share|improve this question
up vote 1 down vote accepted

To set up AptPreferences for a set of packages add a new file in /etc/apt/preferences.d/.

sudo gedit /etc/apt/preferences.d/my-packages-pin

Add add the following lines in that file:

Package: package1 package2
Pin: release o=Ubuntu
Pin-Priority: 900

I will prevent ppa versions to replace packages provided by the main Ubuntu archives

To check if the package pin version run:

sudo apt-cache policy package1


share|improve this answer
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – Mitch Mar 11 '14 at 11:19
You're right, sorry about that. I'll elaborate a better answer. – Sylvain Pineau Mar 11 '14 at 11:43

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.