4 Ways to Disable or Lock Package Updates in Yum and DNF

A package manager is software that allows a user to install new software, upgrade the system, or update specific software, among other tasks. On Linux-based systems, where software often has many dependencies that must be present on the system for complete installation, tools like package managers become essential on every system.

Each Linux distribution ships with its default package manager for the above-mentioned functionalities, but the most commonly found ones are: Yum on RHEL and Fedora systems (where it is being replaced by DNF from Fedora 22+ onwards) and Apt on Debian-based systems.

If you’re looking for an APT tool to block or disable certain specific package updates on Ubuntu/Debian systems, then you should read this article.

DNF (Dandified YUM) is replacing YUM on Fedora systems, which is another one on our list. If explored properly, these package managers can be used for the following functionalities:

  • Installing new software from the repository.
  • Resolving dependencies of the software by installing those dependencies before installing the software.
  • Maintaining a database of dependencies for each software.
  • Downgrading the version of any existing software.
  • Upgrading the kernel version.
  • Listing packages available for installation.

In this guide, we’ll explore four simple methods to disable or lock certain package updates using Yum and DNF commands.

1. Permanently Disable Package Updates Using exclude Option

One of the easiest ways to stop specific packages from being updated is by using the exclude option in the Yum or DNF configuration file, which tells the package manager to avoid updating certain packages.

Open the Yum or DNF configuration file.

sudo nano /etc/yum.conf        #Yum Configuration File
sudo nano /etc/dnf/dnf.conf    #DNF Configuration File

Add the exclude line at the bottom of the file, followed by the package names you want to block.

exclude=kernel* httpd

This prevents the system from updating all kernel-related packages and the Apache web server (httpd).

Exclude Package Updates in DNF
Exclude Package Updates in DNF

Now let’s try to install or update the specified package and see that the Yum or DNF command will disable it from being installed or updated.

sudo dnf install httpd
Preventing Package Installation in Linux
Preventing Package Installation in Linux

2. Temporarily Disable Package Updates Using exclude Option

If you don’t want to modify the configuration file permanently, you can exclude specific packages temporarily by using the --exclude option in the command line when running the Yum or DNF update.

sudo yum update --exclude=nginx php
sudo dnf update --exclude=nginx php

3. Excluding Specific Packages in Repositories

For any package installed from any external source via adding a repository, there is another way to stop its up-gradation in the future. This can be done by editing its repo-name.repo configuration file which is created in /etc/yum/repos.d/ or /etc/yum.repos.d directory.

Open the repository configuration file.

sudo nano /etc/yum.repos.d/repo-name.repo

Add the exclude line under the [repository] section:

exclude=package1 package2

For example, if you want to exclude the mysql package from being updated from the epel repository, open /etc/yum.repos.d/epel.repo and add:

exclude=mysql*

This will block updates for mysql from this specific repository.

4. Disable Package Updates Using versionlock Option

Both Yum and DNF offer plugins that can lock specific versions of packages, preventing them from being updated and this is done using the versionlock plugin.

For Yum:

  • Install versionlock package: sudo yum install yum-plugin-versionlock
  • Lock a specific package version: sudo yum versionlock add httpd
  • To view all locked packages: sudo yum versionlock list
  • To remove a package from the version lock: sudo yum versionlock delete httpd

For Dnf:

  • Install versionlock package: sudo dnf install dnf-plugins-core
  • Lock a specific package version: sudo dnf versionlock add httpd
  • To view all locked packages: sudo dnf versionlock list
  • To remove a package from the version lock: sudo dnf versionlock delete httpd
Conclusion

By using these four methods-modifying the Yum or DNF configuration file, using the --exclude option in commands, utilizing the versionlock plugin, or configuring repository exclusions – you can easily disable or lock package updates in your RPM-based Linux system.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Gunjit Khera
Currently a Computer Science student and a geek when it comes to Operating System and its concepts. Have 1+ years of experience in Linux and currently doing a research on its internals along with developing applications for Linux on python and C.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.