This wiki page will discuss some advanced things you can do to packages to accomplish specific goals. The first thing described is Pinning, this is useful if you want only some things from a newer version of Ubuntu. There is also package holding, which allows you to not update the package.

Introduction to Pinning

Pinning is a process that allows you to remain on a stable release of Ubuntu (or any other debian system) while grabbing packages from a more recent version.

Note however that the processes described below will only work if things like libc6 versions match, so you should probably not do this on an Ubuntu system. I strongly recommend you look at UbuntuBackports before doing this.

Pinning Methods

There are 3 main files you must edit for pinning to even function.

It is important to start out by setting your default release to avoid accidentally upgrading all packages, by editing /etc/apt/apt.conf [in intrepid that is /etc/apt/apt.conf.d/01ubuntu, "intrepid" rather than "hardy", but use the name for the appropriate release of your Ubuntu, eg. "xenial" for 16.04, "bionic" for 18.04] as follows:

APT::Default-Release "hardy";

The second file is:


An example configuration is as follows:

# official ubuntu sites
#### testing  #########
deb hardy main restricted universe multiverse
#### development #########
deb intrepid main restricted universe multiverse

In this example, we're pulling from hardy and intrepid; the versions of Ubuntu at the time of writing; please use the names of your wanted releases, for example 'xenial' for 16.04 LTS 'Xenial Xerus', 'yakkety' for 16.10.

The next file involved is:


The 'preferences' file is where the actual pinning takes place. To pin a package, set its Pin-Priority to higher number. Here's an example:

Package: firefox-3.0
Pin: release n=hardy
Pin-Priority: -10

Package: firefox-3.0
Pin: release n=intrepid
Pin-Priority: 900

In this example, we're giving a higher priority to Firefox from intrepid because we want rc1 instead of beta5. This of course can be done with any package, or even all packages - although in the above example, you likely want to change hardy and intrepid Pin-Priority values around so that hardy is default. For further information please read: man apt_preferences

Debugging Package Priorities

To print out the priorities of each source, run apt-cache policy. For priorities for packages, run apt-cache policy packagename[s].

In Ubuntu, most times, the libc6 version is updated from version to version - it is not the purpose of this page to describe what libc6 is, but needless to say it breaks the above example.

A better method for grabbing things from a development version while not committing your entire machine to that version is as follows:

Add the following line to /etc/apt/sources.list

deb-src intrepid main restricted universe multiverse

Then you'll need to update your repos:

sudo apt-get update 

Now we need to install some packages so we can build the desired software in intrepid:

sudo apt-get build-dep firefox-3.0

Now we can do the following to get the package built from intrepid on our hardy machine:

sudo apt-get -b source -t intrepid firefox-3.0

It will output lots of info on the screen, when it's done (could take a while), you will have rc1 instead of beta5!

Introduction to Holding Packages

Holding a package basically means you're telling the package manager to keep the current version no matter what. This is useful if more recent version of a currently working program breaks after an update.

The following will describe the process of actually holding the package, there are several options to accomplish this:


Starting with Ubuntu 12.04, use Apt to hold one or more packages:

sudo apt-mark hold libxfont1 …

Replace 'libxfont1' with the package(s) you wish to hold.


On older systems, use dpkg:

  • Open a terminal
  • sudo -s and hit enter
  • Enter your password for sudo
    echo libxfont1 hold | dpkg --set-selections

    Replace libxfont1 with the package you want to pin

  • Now run sudo apt-get update and then sudo apt-get upgrade

Removing a Hold

To remove a package from hold, you can run

sudo apt-mark unhold libxfont1 …

Replace 'libxfont1' with the package(s) you wish to unhold.

To see what the next version of the package is, use apt-cache policy packagename (see Debugging Package Priorities above).


To remove pin from Dpkg:

  • Open a terminal
  • sudo -s and hit enter
  • Enter your password for sudo
  • echo libxfont1 install | dpkg --set-selections

    Replace libxfont1 with the package you want to pin

  • Now run sudo apt-get update and then sudo apt-get upgrade

NOTE At the time of the making this Wiki there is not a known way to Pin a package with Update Manager.

Pinning should never be used for installing Debian binary packages on Ubuntu. Ubuntu strongly recommends against using Debian binary packages on Ubuntu,


Example #1: Pinning the ubuntu-x-swat/q-lts-backport-precise PPA

This PPA contains backports of newer Linux kernel and Xorg stack components from quantal to precise.
WARNING: The packages from this PPA are not intended for end users. It is for testing and feedback only aka unsupported!

First, add the PPA to your sources.list:

$ sudo add-apt-repository ppa:ubuntu-x-swat/q-lts-backport

Create and edit a new file in /etc/apt/preferences.d/ directory:

[ /etc/apt/preferences.d/ubuntu-x-swat-q-lts-backport-precise-pin-400 ]
Package: *
Pin: release o=LP-PPA-ubuntu-x-swat-q-lts-backport
Pin-Priority: 400

Verify the pinning priority (here: "xserver-xorg" package):

$ sudo apt-cache policy xserver-xorg

The output should list the "xserver-xorg" package from the new PPA with priority "400" but not as a "Candidate" for upgrading:

  Installed: 1:7.6+12ubuntu1
  Candidate: 1:7.6+12ubuntu1
  Version table:
     1:7.6+12ubuntu1.10 0
        400 precise/main amd64 Packages
 *** 1:7.6+12ubuntu1 0
        500 precise/main amd64 Packages
        100 /var/lib/dpkg/status

This will list all packages from the new PPA which include "lts-quantal" pattern:

$ sudo apt-cache search lts-quantal | sort

Example #2: Pinning the kubuntu-ppa/backports PPA

There exists a PPA for backports of KDE-SC to Ubuntu/precise (latest: v4.9.1), for more details please see also here.

First, add the PPA to your sources.list:

# add-apt-repository ppa:kubuntu-ppa/backports

Create and edit a new file in /etc/apt/preferences.d/ directory to prevent auto-upgrades:

[ /etc/apt/preferences.d/kubuntu-ppa-backports-pin-400 ]
Package: *
Pin: release o=LP-PPA-kubuntu-ppa-backports
Pin-Priority: 400

Simulate an upgrade to new KDE-SC:

# apt-get install -t precise kde-standard --simulate

NOTE-1: You need to pass -t precise to get packages from kubuntu-ppa/backports PPA!
NOTE-2: By choosing kde-standard meta-package you will get a complete KDE-SC installation.
NOTE-3: Drop --simulate to force a real installation.

As listed in Example #1, you can check with apt-cache policy $pkgname the pin-priority.


These documents were used as a foundation for this page, and might give you more background information:

PinningHowto (last edited 2018-02-12 01:47:20 by guiverc)