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.
Table of Contents
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).
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
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.