Debian – How to tell apt to use the latest package by default

aptdebian

I put jessie-backports in my /etc/apt/sources.list, but it seems that apt will not automatically use the packages from backports but older packages.

However, if I use apt-cache show to check the version it shows the latest, and I am able to use apt install xxx=<latest-version> to install it.

How to tell apt always use the latest package by default?

Best Answer

As @cutrightjm has mentioned apt-pinning is the solution.

If you create a file /etc/apt/preferences.d/backports with the following content

Package: *
Pin: release a=stretch-backports
Pin-Priority: 800

apt will always install packages from stretch-backports, except when you pin another package source with a priority higher than 800.

If you want to see all available versions of a package, their priority and which one will be installed, you can use apt-cache policy <packagename>.

Related Question