How to Version Lock RPM Packages in Linux Print

  • 0

Table of Contents

  1. Introduction to RPM Package Version Locking
  2. Version Locking with yum
    • Installing the yum-versionlock Plugin
    • Locking a Package Version
    • Listing Locked Packages
    • Removing a Version Lock
  3. Version Locking with dnf
    • Installing the dnf-plugin-versionlock Plugin
    • Locking a Package Version
    • Listing Locked Packages
    • Removing a Version Lock
  4. Version Locking with zypper
    • Locking a Package Version
    • Listing Locked Packages
    • Removing a Version Lock
  5. Version Locking with apt (Debian/Ubuntu)
    • Holding a Package
    • Listing Held Packages
    • Unholding a Package
  6. Conclusion

1. Introduction to RPM Package Version Locking

RPM (Red Hat Package Manager) is a powerful package management system used by several Linux distributions, including Red Hat, CentOS, Fedora, and openSUSE. Locking a package version ensures that a specific version of a package remains installed and prevents updates to that package. This is particularly useful when you need to maintain a stable environment or when a newer version of a package introduces changes that are not compatible with your current setup.

2. Version Locking with yum

Installing the yum-versionlock Plugin

For CentOS/RHEL 7 and earlier, the yum package manager is used. To lock a package version, you need to install the yum-versionlock plugin.

sudo yum install yum-plugin-versionlock

 

Locking a Package Version

 

To lock a specific version of a package, use the following command syntax:
sudo yum versionlock <package-name>-<version>

 

Example:

 

To lock the `httpd` package to version `2.4.6-90.el7.centos.1`:
sudo yum versionlock httpd-2.4.6-90.el7.centos.1

 

Listing Locked Packages

 

To see which packages are locked, use:
sudo yum versionlock list

 

Example Output:
0: httpd-2.4.6-90.el7.centos.1.*

 

Removing a Version Lock

 

To remove a version lock from a package:
sudo yum versionlock delete <package-name>

 

Example:
sudo yum versionlock delete httpd

 

3. Version Locking with dnf

 

For CentOS/RHEL 8 and later, and Fedora, the `dnf` package manager is used. You will need the `dnf-plugin-versionlock` plugin.

 

Installing the `dnf-plugin-versionlock` Plugin
sudo dnf install 'dnf-command(versionlock)'

 

Locking a Package Version

 

To lock a specific version of a package, use the following command syntax:
sudo dnf versionlock <package-name>-<version>

 

Example:

 

To lock the `httpd` package to version `2.4.37-30.module_el8.3.0+703+ba5d6dcd`:
sudo dnf versionlock httpd-2.4.37-30.module_el8.3.0+703+ba5d6dcd

 

Listing Locked Packages

 

To see which packages are locked, use:
sudo dnf versionlock list

 

Example Output:
Last metadata expiration check: 0:01:23 ago on Wed 24 Feb 2021 03:27:16 PM CET.
0: httpd-2.4.37-30.module_el8.3.0+703+ba5d6dcd.*

 

Removing a Version Lock

 

To remove a version lock from a package:
sudo dnf versionlock delete <package-name>

 

Example:
sudo dnf versionlock delete httpd

 

4. Version Locking with `zypper`

 

For openSUSE and SUSE Linux Enterprise Server (SLES), the `zypper` package manager is used.

 

Locking a Package Version

 

To lock a specific version of a package:
sudo zypper addlock <package-name>-<version>

 

Example:

 

To lock the `httpd` package to version `2.4.43-3.9.1`:
sudo zypper addlock httpd-2.4.43-3.9.1

 

Listing Locked Packages

 

To see which packages are locked:
sudo zypper locks

 

Example Output:
# | Name | Type | Repository
--+-------+---------+-----------
1 | httpd | package | (any)

 

Removing a Version Lock

 

To remove a version lock from a package:
sudo zypper removelock <package-name>

 

Example:
sudo zypper removelock httpd

 

5. Version Locking with `apt` (Debian/Ubuntu)

 

While `apt` does not use RPM, you can hold packages at specific versions to prevent them from being updated.

 

Holding a Package

 

To hold a package at its current version:
sudo apt-mark hold <package-name>

 

Example:
sudo apt-mark hold apache2

 

Listing Held Packages

 

To see which packages are held:
apt-mark showhold

 

Example Output:
apache2

 

Unholding a Package

 

To unhold a package and allow it to be updated:
sudo apt-mark unhold <package-name>

 

Example:
sudo apt-mark unhold apache2

 

6. Conclusion

Version locking RPM packages is a crucial technique for maintaining stability in your Linux environment. By following the steps outlined in this guide, you can ensure that specific versions of packages remain installed, preventing unwanted updates that could potentially disrupt your system or applications. Whether you are using yum, dnf, zypper, or apt, the process is straightforward and helps maintain a predictable and stable environment.

For further assistance or more detailed guides, you can refer to the documentation specific to your Linux distribution or consult the knowledge base at Domain India Knowledgebase or submit a ticket at Domain India Support.


Was this answer helpful?

« Back