{"id":47914,"date":"2025-01-05T13:20:41","date_gmt":"2025-01-05T13:20:41","guid":{"rendered":"https:\/\/ubuntuhandbook.org\/?p=47914"},"modified":"2025-01-05T13:20:41","modified_gmt":"2025-01-05T13:20:41","slug":"change-priority-ubuntu","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2025\/01\/change-priority-ubuntu\/","title":{"rendered":"Change the Priority of PPAs or Apt Package Repositories in Ubuntu"},"content":{"rendered":"<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/softwarecenter-logo.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-thumbnail wp-image-38890\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/softwarecenter-logo-250x250.webp\" alt=\"\" width=\"250\" height=\"250\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/softwarecenter-logo-250x250.webp 250w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/softwarecenter-logo-300x300.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/softwarecenter-logo-600x600.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/softwarecenter-logo-768x768.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/softwarecenter-logo.webp 1200w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/a><\/p>\n<p>This is a step by step guide shows how to set the priority of certain packages, launchpad PPAs, and\/or other apt repositories in Ubuntu, Debian, Linux Mint, and their based systems.<\/p>\n<p>Besides using the default system repositories, we can also install additional packages from third-party or software&#8217;s own repositories.<\/p>\n<p>For example, user may update LibreOffice office suite via the <a href=\"https:\/\/launchpad.net\/~libreoffice\/+archive\/ubuntu\/ppa\" target=\"_blank\" rel=\"noopener\">Ubuntu PPA<\/a>, install Spotify, Google Chrome, Edge from their own repositories, or install tons of media apps from <a href=\"https:\/\/www.deb-multimedia.org\/\" target=\"_blank\" rel=\"noopener\">deb multimedia repository<\/a> in Debian.<\/p>\n<p><!--more--><\/p>\n<p>Due to mixed software sources, you have multiple versions of same app package, but you may want to install and keep an older or certain version. Or you added a third-party repository, but only want to install single or few packages from it, while keep all others being blocked.<\/p>\n<p>In the cases, you need to set the priority for certain packages or repositories, and here&#8217;s how!<\/p>\n<p><b>NOTE: This tutorial does NOT work for Flatpak and Snap packages, as they run in sandbox environment.<\/b><\/p>\n<h3>Step 1: Find out the key attribute for the target repository<\/h3>\n<p>Before getting started, you need to first find out the key attribute to identify the target package repository.<\/p>\n<p><b>1.<\/b> First, press <code>Ctrl+Alt+T<\/code> on keyboard to open up a terminal window. Then, run command to refresh the package cache:<\/p>\n<pre>sudo apt update<\/pre>\n<p><b>2.<\/b> Next, <b>list all local repositories as well as their properties<\/b> by running the command below:<\/p>\n<pre>apt policy<\/pre>\n<p>In the output, find out the target PPA or package repository, and <b>the unique attributes (usually &#8216;o=xxx&#8217;) to make it different to others.<\/b><\/p>\n<p>In my case (see the screenshot below), I can use:<\/p>\n<ul>\n<li>The &#8216;release&#8217; attribute: <code>o=LP-PPA-ubuntuhandbook1-testarm<\/code> or <code>l=testarm<\/code> to identify my testarm PPA.<\/li>\n<li>The &#8216;release&#8217; attribute: <code>o=Spotify<\/code> or &#8216;origin&#8217; attribute <code>repository.spotify.com<\/code> to identify the Spotify repository<\/li>\n<li>The &#8216;release&#8217; attribute: <code>o=aptian<\/code> or <code>l=aptian<\/code>, or &#8216;origin&#8217; attribute <code>minecraft-linux.github.io<\/code> to identify the minecraft github repository.<\/li>\n<li>Or even <code>o=Ubuntu<\/code> for all Ubuntu official repositories, <code>c=multiverse<\/code> for the multiverse, <code>c=restricted<\/code> for the restricted repositories.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/01\/apt-policy.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-47916\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/01\/apt-policy-700x540.webp\" alt=\"\" width=\"610\" height=\"471\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/01\/apt-policy-700x540.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/01\/apt-policy-300x231.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/01\/apt-policy-768x592.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/01\/apt-policy.webp 1039w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<h3>Step 2: Create\/Edit Apt Preferences Config file<\/h3>\n<p>The apt package manager reads the package priority rules from files under <code>\/etc\/apt\/preferences.d<\/code> directory.<\/p>\n<p><b>1.<\/b> Simply open terminal (Ctrl+Alt+T) and run command to create a file (with whatever name) under that directory:<\/p>\n<pre>sudo nano \/etc\/apt\/preferences.d\/mozillateamppa<\/pre>\n<p>Here I use <code>nano<\/code> command line text editor that works in most Linux desktops and servers. You may replace it accordingly, such as\u00a0 <code>gnome-text-editor<\/code> for GNOME, <code>pluma<\/code> for MATE, or <code>mousepad<\/code> for XFCE.<\/p>\n<p><b>2.<\/b> When file opens, add rules accordingly.<\/p>\n<p>For example, set higher priority (1001) for all packages from Mozilla Team PPA:<\/p>\n<pre>Package: *\r\nPin: release o=LP-PPA-mozillateam\r\nPin-Priority: 1001<\/pre>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/01\/mozilla-ppa-priority.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-47917\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/01\/mozilla-ppa-priority-700x453.webp\" alt=\"\" width=\"610\" height=\"395\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/01\/mozilla-ppa-priority-700x453.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/01\/mozilla-ppa-priority-300x194.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/01\/mozilla-ppa-priority-768x497.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/01\/mozilla-ppa-priority.webp 917w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>As you see, each rule has <b>3 lines<\/b>. They include:<\/p>\n<ul>\n<li><b>Package:<\/b> &#8211; specify which package or packages to set priority. Use value <b>*<\/b> (for any package), exact package name, or regex patterns.<\/li>\n<li><b>Pin:<\/b> &#8211; specify which repository the packages are from. Use <code>release o=xxx<\/code>, <code>release l=xxx<\/code>, or <code>origin xxx.xxx.xxx<\/code> according to step 1.<\/li>\n<li><b>Pin-Priority:<\/b> &#8211; set the priority number for the specified packages.<\/li>\n<\/ul>\n<p>As the screenshot above shows, you may add as many rules as possible, according what you need.<\/p>\n<p>For example, the rules below tell to set higher priority for firefox packages from MozillaTeam PPA, while set all others to -1.<\/p>\n<pre>Package: firefox*\r\nPin: release o=LP-PPA-mozillateam\r\nPin-Priority: 1001\r\n\r\nPackage: *\r\nPin: release o=LP-PPA-mozillateam\r\nPin-Priority: -1<\/pre>\n<p>Rather than setting priority for packages from certain repository, you may also set package in certain version. For example, set <code>perl<\/code> at version <code>5.38.2-3.2build2<\/code> with 1001 priority.<\/p>\n<pre>Package: perl\r\nPin: version 5.38.2-3.2build2\r\nPin-Priority: 1001<\/pre>\n<p><b>Apt by default will install the package with highest priority, unless you specify version number in the <code>apt<\/code> command, e.g., sudo apt install firefox=133.0.3-0build3&#8230;<\/b><\/p>\n<p>The default package priority in Debian and Ubuntu is <b>500<\/b>. And, if you set a package priority to number:<\/p>\n<ul>\n<li><b>1000<\/b> or <b>higher<\/b>, then apt command will install that version and even downgrade an already installed package.<\/li>\n<li>from <b>501<\/b> to <b>999<\/b> (higher than default 500), then apt will install that version, even it&#8217;s older than other versions. But it won&#8217;t downgrade if higher version already installed.<\/li>\n<li>from <b>1<\/b> to <b>499<\/b>, only install if there&#8217;s no other version available in local repositories.<\/li>\n<li><b>-1<\/b> or <b>lower<\/b>, prevent the version from being installed, unless you specify version number in apt command, or use <code>-t \"o=unique-release-attribute\"<\/code> (won&#8217;t work if another package version available with higher priority) to tell to install from certain repository.<\/li>\n<\/ul>\n<p>For more details, run <code>man apt_preferences<\/code> command in terminal to tell.<\/p>\n<h3>Step 3: Apply changes and Verify<\/h3>\n<p>After editing the config file, press <code>Ctrl+S<\/code> to save and <code>Ctrl+X<\/code> to exit.<\/p>\n<p>Finally, <b>apply change<\/b> by running command:<\/p>\n<pre>sudo apt update<\/pre>\n<p>And, verify by <code>apt policy<\/code> command + target package name. For example, run command to check the firefox package:<\/p>\n<pre>apt policy firefox<\/pre>\n<p>In the output, it will show available versions of the package, as well as their priority.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/01\/verify-priority.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-47918\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/01\/verify-priority-700x541.webp\" alt=\"\" width=\"610\" height=\"471\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/01\/verify-priority-700x541.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/01\/verify-priority-300x232.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/01\/verify-priority.webp 703w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>This is a step by step guide shows how to set the priority of certain packages, launchpad PPAs, and\/or other apt repositories in Ubuntu, Debian, Linux Mint, and their based systems. Besides using the default system repositories, we can also install additional packages from third-party or software&#8217;s own repositories. For example, user may update LibreOffice [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":38890,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[2022],"class_list":["post-47914","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","tag-apt"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/47914","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/comments?post=47914"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/47914\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media\/38890"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=47914"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=47914"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=47914"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}