• Contact
  • Contact Us
  • Disclamer
  • Home 1
  • Home 2
  • Home 3
  • Privacy Policy
Saturday, May 10, 2025
How VPS - How to use/setup VPS
  • Login
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System Linux

How to Disable/Lock or Blacklist Package Updates using Apt Tool

How VPS by How VPS
November 2, 2018
in Linux, Operating System
0
0
SHARES
34
VIEWS
Share on FacebookShare on Twitter

Contents

  1. 1. Disable/Lock Package Using ‘apt-mark’ with hold/unhold Option
  2. Blocking Package Updates Using APT Preferences File
  3. Blacklist a Package Update using APT Autoremove File
  4. Custom Package Selection for Update
  5. Conclusion

APT means Advanced Packaging Tool is another package manager found on Linux based systems. Initially designed as a front-end for dpkg to work with .deb packages, apt has succeeded to show his visibility on Mac OS, Open Solaris etc.

How to Disable/Lock or Blacklist Package Updates using Apt Tool

Disable Package Updates in Debian and Ubuntu Using APT

Want to learn and master about APT and DPKG commands to manage Debian package management, then use our in-depth articles which will cover more than 30+ examples on both tools.

25 Useful APT Commands for Debian/Ubuntu Package Management
15 Useful Dpkg Commands for Package Management in Debian/Ubuntu

In this article we will see various techniques to disable/lock package from install, upgrade and remove in Debian Linux and its derivatives such as Ubuntu and Linux Mint.

1. Disable/Lock Package Using ‘apt-mark’ with hold/unhold Option

The command apt-mark will mark or unmark a software package as being automatically installed and it is used with option hold or unhold.

  1. hold – this option used to mark a package as held back, which will block the package from being installed, upgraded or removed.
  2. unhold – this option used to remove a previously set hold on a package and allow to install, upgrade and remove package.

For example, for making a package say apache2 unavailable for install, up-gradation or uninstall, you can use following command at the terminal with root privileges:

# apt-mark hold apache2

To make this package available for update, just replace ‘hold‘ with ‘unhold‘.

# apt-mark unhold apache2
How to Disable/Lock or Blacklist Package Updates using Apt Tool

Hold Package Update in Ubuntu/Debian

Blocking Package Updates Using APT Preferences File

Another way to block updates of a specific package is to add its entry in /etc/apt/preferences or /etc/apt/preferences.d/official-package-repositories.pref file. This file holds responsibility of updating or blocking certain package updates according to priority specified by the user.

To block the package, you just need to enter its name, additional feature, and to what priority you want to take it to. Here, priority < 1 would block the package.

For blocking any package, just enter its details in file /etc/apt/preferences like this:

Package: <package-name> (Here, '*' means all packages)
Pin: release *
Pin-Priority: <less than 0>

For example to block updates for package apache2 add the entry as shown:

Package: apache2
Pin: release o=Ubuntu
Pin-Priority: 1
How to Disable/Lock or Blacklist Package Updates using Apt Tool

Block Package Update Using Preference File

We can use other options with release keyword for further identifying the package on which we are applying the Pin Priority. Those keywords are:

  1. a -> Archive
  2. c -> Component
  3. o -> Origin
  4. l -> Label
  5. n -> Architecture

like:

Pin: release o=Debian,a=Experimental

Would mean to pull the stated package from Debian package experimental archive.

Blacklist a Package Update using APT Autoremove File

Another way to blacklist a package from installation is to update its entry in one of the files contained in /etc/apt/apt.conf.d/ directory which is 01autoremove.

Sample file is shown below:

APT
{
  NeverAutoRemove
  {
        "^firmware-linux.*";
        "^linux-firmware$";
  };

  VersionedKernelPackages
  {
        # linux kernels
        "linux-image";
        "linux-headers";
        "linux-image-extra";
        "linux-signed-image";
        # kfreebsd kernels
        "kfreebsd-image";
        "kfreebsd-headers";
        # hurd kernels
        "gnumach-image";
        # (out-of-tree) modules
        ".*-modules";
        ".*-kernel";
        "linux-backports-modules-.*";
        # tools
        "linux-tools";
  };

  Never-MarkAuto-Sections
  {
        "metapackages";
        "restricted/metapackages";
        "universe/metapackages";
        "multiverse/metapackages";
        "oldlibs";
        "restricted/oldlibs";
        "universe/oldlibs";
        "multiverse/oldlibs";
  };
};

Now, for blacklisting any package, just need to enter its name in Never-MarkAuto-Sections. Just enter the name of the package at the end in Never-MarkAuto-Section and Save and Close the file. This would block apt for searching for further updates of that package.

For example, to blacklist a package from being update add the entry as shown:

Never-MarkAuto-Sections
  {
        "metapackages";
        "restricted/metapackages";
        "universe/metapackages";
        "multiverse/metapackages";
        "oldlibs";
        "restricted/oldlibs";
        "universe/oldlibs";
        "multiverse/oldlibs";
        "apache2*";
  };
};

Custom Package Selection for Update

Another alternative for this is to choose what you want to update. The apt tool gives you freedom to choose what you want to update, but for this you should have knowledge about what all packages are available for up-gradation.

For such a thing, following set of commands can prove to be helpful:

a. To List what packages have updates pending.

# apt-get -u -V upgrade

b. To install only selective packages.

# apt-get --only-upgrade install <package-name>
How to Disable/Lock or Blacklist Package Updates using Apt Tool

Update Selected Packages

Conclusion

In this article, we’ve explained few ways to disable/block or blacklist package updates using APT way. If you know any other preferred way, do let us know via comments or if you were looking for yum command to disable/lock package update, then read this below article.

Disable/Lock Package Updates Using Yum in CentOS/RHEL

Source: tecmint.com

Tags: Linux Commandslinux guidelinux vps setup guide
Previous Post

How to Delete User Accounts with Home Directory in Linux

Next Post

5 Ways to Keep Remote SSH Sessions and Processes Running After Disconnection

Next Post

5 Ways to Keep Remote SSH Sessions and Processes Running After Disconnection

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

No Result
View All Result

Recent Post

Install Imagemagick on CentOS
CentOS

Install Imagemagick on CentOS

by How VPS
June 28, 2023
0

This is how I installed Imagemagick on a vanilla CentOS server Start off by installing the prerequisites yum install php-pear...

Read more
how to Check phpinfo

How to Check phpinfo of Hosting or VPS?

June 28, 2023
Failed to download metadata for repo 'appstream' on Centos 8

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020

Recent News

  • Install Imagemagick on CentOS
  • How to Check phpinfo of Hosting or VPS?
  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

Category

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel
  • About
  • Advertise
  • Careers
  • Contact

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Thabet