{"id":49734,"date":"2025-09-25T13:53:07","date_gmt":"2025-09-25T13:53:07","guid":{"rendered":"https:\/\/ubuntuhandbook.org\/?p=49734"},"modified":"2025-09-25T13:53:07","modified_gmt":"2025-09-25T13:53:07","slug":"block-certain-app-packages","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2025\/09\/block-certain-app-packages\/","title":{"rendered":"Block Certain App Packages in Ubuntu 25.10 [New Apt Method]"},"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 block certain app packages from Ubuntu local repositories, PPAs, or other apt repositories in Ubuntu 25.10 and higher.<\/p>\n<p>Previously, we can <a href=\"https:\/\/ubuntuhandbook.org\/index.php\/2025\/01\/change-priority-ubuntu\/\" target=\"_blank\" rel=\"noopener\">set package pin-priority<\/a> to prevent from or prior to installing certain app packages. Now, in Debian\/Ubuntu with <code>apt 3.1+<\/code>, a new method is available to include\/exclude packages for specified apt sources (repositories).<\/p>\n<p><!--more--><\/p>\n<p>Say you have a Ubuntu PPA or apt repository installed in Ubuntu. It contains many app packages, but you only need one or few of them. In the case, you may use the new method below to completely exclude all other packages from that repository, so they are not installable with any <code>apt<\/code> option or other graphical tool.<\/p>\n<p><b>NOTE 1: This tutorial only works for classic <code>.deb<\/code> packages. Though, you may use the method to block snap and flatpak entirely.<\/b><\/p>\n<p><b>NOTE 2: This tutorial needs apt 3.1+, meaning Debian Unstable\/Testing or Ubuntu 25.10+.<\/b><\/p>\n<h3>Step 1: Find out what packages available in the repository<\/h3>\n<p>Before getting started, it might be helpful to first find out all the package names available in the target PPA or apt repository.<\/p>\n<p><b>For Ubuntu desktop<\/b>, you can simply install and launch <b>Synaptic package manager<\/b>. Then, choose &#8220;Origin&#8221; in left and select the target repository to show all the packages.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/synaptic-origin.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-49735\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/synaptic-origin-700x449.webp\" alt=\"\" width=\"610\" height=\"391\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/synaptic-origin-700x449.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/synaptic-origin-300x192.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/synaptic-origin-768x493.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/synaptic-origin.webp 1102w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p><b>For server without GUI<\/b>, you may view the package index files instead.<\/p>\n<ul>\n<li>First, run the command below to update package index:\n<pre>sudo apt update<\/pre>\n<\/li>\n<li>Next, print all the package index files under <code>\/var\/lib\/apt\/lists<\/code> directory:\n<pre>ls \/var\/lib\/apt\/lists\/ |grep Packages<\/pre>\n<p>The files contain the package names, their versions, origin, maintainers, sizes, and hash-code, etc information.<br \/>\n<a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/apt-lists.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-49737\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/apt-lists-700x581.webp\" alt=\"\" width=\"610\" height=\"506\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/apt-lists-700x581.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/apt-lists-300x249.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/apt-lists-768x637.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/apt-lists.webp 946w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/li>\n<li>In last command output, find out the target file-name for your repository, then use the command below to filter and show only package names in it:\n<pre>grep ^Package \/var\/lib\/apt\/lists\/ppa.launchpadcontent.net_ubuntuhandbook1_apps_ubuntu_dists_noble_main_binary-amd64_Packages<\/pre>\n<p>Here you need to replace the long file-name with yours.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/grep-ppa-package.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-49736\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/grep-ppa-package-700x341.webp\" alt=\"\" width=\"610\" height=\"297\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/grep-ppa-package-700x341.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/grep-ppa-package-300x146.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/grep-ppa-package-768x375.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/grep-ppa-package.webp 898w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>For choice, you may install <code>aptitude<\/code>, then use the command below instead to list all packages from target repository:<\/p>\n<pre>aptitude search \"?origin (LP-PPA-ubuntuhandbook1-apps)\"<\/pre>\n<p><i>Here replace <code>LP-PPA-ubuntuhandbook1-apps<\/code> accordingly, while <code>ubuntuhandbook1<\/code> is PPA maintainer name, and <code>apps<\/code> is PPA name. For other repositories, run <code>apt-cache policy |grep \"o=\"<\/code> to list and get the target value of &#8220;o=&#8221;.<\/i><\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/aptitude-search-repo.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-49738\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/aptitude-search-repo-700x497.webp\" alt=\"\" width=\"610\" height=\"433\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/aptitude-search-repo-700x497.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/aptitude-search-repo-300x213.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/aptitude-search-repo-768x545.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/aptitude-search-repo.webp 802w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<h3>Step 2: Edit source files to block packages<\/h3>\n<p>For Ubuntu, all the apt sources are handled by <code>.sources<\/code> and <code>.list<\/code> files under <code>\/etc\/apt\/sources.list.d<\/code> directory.<\/p>\n<p><b>To block specific packages from Ubuntu official repositories,<\/b> open terminal (Ctrl+Alt+T) and run command to edit the file below:<\/p>\n<pre>sudo nano \/etc\/apt\/sources.list.d\/ubuntu.sources<\/pre>\n<p>For next Ubuntu 26.04, there&#8217;ll be <code>ubuntu-esm-apps.sources<\/code> and <code>ubuntu-esm-infra.sources<\/code> in that directory for ESM packages if Ubuntu Pro is enabled.<\/p>\n<p>When file opens, simply add <code>Exclude: package1 package2 package3 ...<\/code> in the end of the 2 sections.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/exclude-flatpak-snap.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-49739\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/exclude-flatpak-snap-700x479.webp\" alt=\"\" width=\"610\" height=\"417\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/exclude-flatpak-snap-700x479.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/exclude-flatpak-snap-300x205.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/exclude-flatpak-snap-768x525.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/exclude-flatpak-snap.webp 1193w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>In the screenshot above, it tells to block <code>flatpak<\/code>, <code>snap<\/code>, and <code>snapd<\/code> packages. After saved file (Ctrl+S, then Ctrl+X), run <b>sudo apt update<\/b> to apply changes.<\/p>\n<p><b>To block certain PPA packages<\/b>, simply launch &#8220;Software &amp; Updates&#8221; utility and navigate to &#8220;Other Software tab&#8221;.<\/p>\n<p>Then, highlight the PPA source and edit it. Finally, click <b>Add<\/b> an additional fields, and:<\/p>\n<ul>\n<li>either set key <code>Include<\/code> and value <code>package1 package2 package3<\/code>, so to block all others.<\/li>\n<li>or set key <code>Exclude<\/code> and value <code>package1 package2 ...<\/code> to block certain packages.<\/li>\n<\/ul>\n<p>Also refresh cache via either <code>sudo apt update<\/code> or Software Updater after saving the changes.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/apt-include-gui.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-49741\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/apt-include-gui-700x488.webp\" alt=\"\" width=\"610\" height=\"425\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/apt-include-gui-700x488.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/apt-include-gui-300x209.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/apt-include-gui-768x535.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/apt-include-gui.webp 957w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p><b>NOTE: When using &#8220;Include&#8221; (leaving others blocked), don&#8217;t forget to also include the dependency packages (if any) in that repository!<\/b><\/p>\n<p><b>For server without GUI,<\/b> run commands below and finally refresh cache.<\/p>\n<ul>\n<li>First, list and find out the target source file:\n<pre>ls \/etc\/apt\/sources.list.d<\/pre>\n<\/li>\n<li>Then, edit the file (replace file-name with yours):\n<pre>sudo nano \/etc\/apt\/sources.list.d\/ubuntuhandbook1-ubuntu-apps-questing.sources<\/pre>\n<p>Finally, add new line with either <code>Include: package1 package2<\/code> or <code>Exclude: package<\/code> accordingly<\/li>\n<\/ul>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/apt-include.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-49742\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/apt-include-700x372.webp\" alt=\"\" width=\"610\" height=\"324\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/apt-include-700x372.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/apt-include-300x160.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/apt-include-768x408.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/apt-include.webp 1025w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p><b>For apt repository installed in the classic <code>.list<\/code> file,<\/b> edit it and add the <code>include=\"package\"<\/code> or <code>exclude=\"package\"<\/code> section between the brackets after &#8216;signed-by&#8217; section.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/apt-include-list.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-49743\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/apt-include-list-700x365.webp\" alt=\"\" width=\"610\" height=\"318\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/apt-include-list-700x365.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/apt-include-list-300x157.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/apt-include-list-768x401.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/09\/apt-include-list.webp 1081w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>And, finally run <code>sudo apt update<\/code> to apply changes.<\/p>","protected":false},"excerpt":{"rendered":"<p>This is a step by step guide shows how to block certain app packages from Ubuntu local repositories, PPAs, or other apt repositories in Ubuntu 25.10 and higher. Previously, we can set package pin-priority to prevent from or prior to installing certain app packages. Now, in Debian\/Ubuntu with apt 3.1+, a new method is available [&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-49734","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\/49734","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=49734"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/49734\/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=49734"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=49734"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=49734"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}