Posted on
Administration

Blacklisting packages from updates in APT

Author
  • User
    Linux Bash
    Posts by this author
    Posts by this author

Title: How to Blacklist Packages from Updates Using APT, DNF, and Zypper on Linux

Keeping your Linux system up-to-date is critical for ensuring security and stability but sometimes, there are instances when you might not want to update certain packages. In this article, we'll explore how to blacklist or hold packages from being updated in various Linux package managers, including APT (used in Debian-based systems), DNF (utilized in Fedora and its derivatives), and Zypper (the command line interface of openSUSE).

Blacklisting Packages with APT (Advanced Package Tool)

APT is the package management system used by Debian and its derivatives like Ubuntu. To prevent a package from being updated, you can hold it using the apt-mark command. This is particularly useful if updating that package would cause issues with your system or disrupt a service.

Step by Step Guide:

  1. Open your terminal.
  2. Check the current status of the package (optional): bash sudo apt-mark showhold
  3. Hold the package:

    sudo apt-mark hold package-name
    

    Replace package-name with the name of the package you wish to hold.

  4. To unhold if needed in the future:

    sudo apt-mark unhold package-name
    

Using DNF (Dandified Yum) in Fedora-based systems

DNF replaces the older YUM package manager in Fedora systems. It manages packages by resolving dependencies and providing automatic updates for your software. To exclude a package from being updated in DNF, you need to add it to the exclude list in the DNF configuration.

Step by Step Guide:

  1. Open your terminal.
  2. Edit the DNF configuration file: bash sudo nano /etc/dnf/dnf.conf
  3. Add the exclude directive under the [main] section. For example, to exclude nginx from updates, add:

    exclude=nginx*
    

    You can add multiple packages by separating them with a space.

  4. Save and close the file. DNF will now ignore the packages specified when performing updates.

Blacklisting Packages with Zypper in openSUSE

Zypper is an advanced package management tool which makes use of the powerful zypp library. To skip updates for a specific package in Zypper:

Step by Step Guide:

  1. Open your terminal.
  2. Add a package to the lock list:

    sudo zypper addlock package-name
    

    Replace package-name with the name of the package you wish to exclude from updates.

  3. To view currently locked packages:

    sudo zypper locks
    
  4. To remove a lock from a package:

    sudo zypper removelock package-name
    

Summary

Blacklisting or holding updates for certain packages can be crucial for maintaining custom setups or preventing incompatible updates from being applied. Each package manager in Linux offers a method to achieve this, safeguarding your system's stability while still receiving general updates. Whether you're running a Debian, Fedora, or openSUSE system, managing your software updates precisely is straightforward with these steps.

Remember to periodically review your list of held or excluded packages. Software is continuously evolving, and an update you previously needed to avoid may eventually become beneficial or necessary.