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.


1 Answer 1


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

Visit https://help.ubuntu.com/community/PinningHowto

  • 1
    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, 2014 at 11:19
  • You're right, sorry about that. I'll elaborate a better answer. Mar 11, 2014 at 11:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .