How to Pin a Package in Debian or Ubuntu -- to stop automatic upgrades of the package

If you always wanted to know how to pin that one package so it won't get upgraded, here's how.

You create a file in /etc/apt/preferences.d, e.g. /etc/apt/preferences.d/xorg
The contents must look like this:

"Package: xorg
Pin: version 5:55ubuntu1
Pin-Priority: 1001"

You get the right version number for Pin: with apt-cache policy. Done! If you like this post, you can share it, check out the related posts section below and subscribe to one of the RSS feeds so you don't miss the next one.


  1. Awesome, worked on debian testing to pin consolekit which was disallowing mounting my standard users. Thanks.

  2. welcome! thanks for the feedback!


I appreciate comments. Feel free to write anything you wish. Selected comments and questions will be published.