Posted on
Administration

Handling "held" packages in APT

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

Understanding and Managing "Held" Packages in APT

When working with Linux operating systems, software package management is a vital skill for system administrators and enthusiasts alike. One common scenario that users encounter is dealing with "held" packages. In this article, we'll explore what holding packages means, its implications, and how to manage held packages in different package management systems including APT (used in Debian and its derivatives like Ubuntu), DNF (used in Fedora), and Zypper (used in openSUSE).

What Does it Mean to Hold a Package?

In the context of software management, "holding" a package prevents the package from being automatically installed, upgraded, or removed by the package management system. This can be crucial for maintaining system stability or ensuring that manually installed versions of software aren't overwritten by system updates.

Handling Held Packages in APT

APT (Advanced Package Tool) is the default package manager for Debian and derivatives. Here’s how you can handle held packages in APT.

  • Checking Held Packages:

    apt-mark showhold
    

    This command lists all packages that are currently held in your system.

  • Holding a Package:

    sudo apt-mark hold package_name
    

    Replace package_name with the name of the package you want to hold. This will prevent the package from being automatically updated or removed.

  • Unholding a Package:

    sudo apt-mark unhold package_name
    

    This command removes the hold status, allowing the package to receive updates again.

Handling Held Packages in DNF

DNF (Dandified YUM) is the default package manager for Fedora. While DNF does not use the term "hold" in the same way APT does, it offers a similar feature called "version locking".

  • Installing the Plugin:

    sudo dnf install dnf-plugins-core
    

    This command installs the necessary plugin to enable version locking.

  • Locking a Package:

    sudo dnf versionlock add package_name
    

    This will lock the specified package to its current version.

  • Listing Locked Packages:

    sudo dnf versionlock list
    

    This lists all packages whose versions have been locked.

  • Unlocking a Package:

    sudo dnf versionlock delete package_name
    

    This command removes the version lock.

Handling Held Packages in Zypper

Zypper is the command line interface of ZYpp package manager for installing, removing, and managing packages in openSUSE and SLE (SUSE Linux Enterprise). It also has features for managing package holds.

  • Adding a Package Lock:

    sudo zypper addlock package_name
    

    This command will prevent the package from being updated or removed.

  • Listing Locked Packages:

    sudo zypper locks
    

    Shows all current package locks.

  • Removing a Package Lock:

    sudo zypper removelock package_name
    

    This command will allow the package to be updated again.

Conclusion

Holding or locking packages is a powerful tool in managing dependencies and system stability across updates. Whether you’re using APT, DNF, or Zypper, understanding how to effectively manage package states ensures you have the control you need over your system’s software environment. Always be cautious and aware of the implications of holding packages, especially when dealing with security updates or critical bug fixes.