Support > About cybersecurity > Methods for disabling or locking package updates in Yum and DNF
Methods for disabling or locking package updates in Yum and DNF
Time : 2025-02-05 15:43:39
Edit : Jtti

A package manager is a type of software that allows users to install new software, upgrade systems, update specific software, and so on. A lot of software in Linux has dependencies that must be present on the system to complete, so tools such as package managers are needed on every system.

Linux distributions all come with a default package manager for the above functions, DNF (Dandified YUM) is replacing YUM on Fedora systems, package managers can implement the installation of new software from the repository, resolve software dependencies by installing dependencies before installing the software, maintain each software dependency database, Downgrade any existing software versions, upgrade kernel versions, and list packages available for installation.

If you want to organize updates for specific packages, you can use either Yum or DNF's configuration file by opening:

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

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

Add the following at the bottom of the file, followed by the name of the package you want to block:

exclude=kernel* httpd

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

Then verify that updates to the specified package have been blocked:

sudo dnf install httpd

If you can't keep modifying the configuration file, you can also use command-line options to temporarily exclude specific packages when Yum or DNF updates:

sudo yum update --exclude=nginx php

sudo dnf update --exclude=nginx php

You can also edit the repo-name.repo configuration file created in the /etc/yum/repos.d directory to block the upgrade by adding any packages that the repository installs from any external source.

To open the configuration file:

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

Add the following line [repository] under this section:

Exclude = package1 package2, if want to mysql from epel repository updates to eliminate the package, please open the/etc/yum repos. D/epel. Repo and add:

exclude=mysql*

This prevents mysql updates from that particular repository.

Both Yum and DNF provide plug-ins that lock specific versions of packages and prevent them from being updated, which is done using the versionlock plug-in. Yum Install versionlock plug-in:

sudo yum install yum-plugin-versionlock

To lock specific package versions:

sudo yum versionlock add httpd

View all locked packages:

sudo yum versionlock list

To remove a package from a version lock:

sudo yum versionlock delete httpd

To install the versionlock package for Dnf:

sudo dnf install dnf-plugins-core

To lock specific package versions:

sudo dnf versionlock add httpd

View all locked packages:

sudo dnf versionlock list

To remove a package from a version lock:

sudo dnf versionlock delete httpd

Relevant contents

The Linux implementation of fkill terminates processes interactively Espanso Open source text extender to improve typing efficiency Key differences and detailed comparisons between 32-bit and 64-bit systems What to do if the temporary file on the server has no permission What is the ping value and access speed of the Canadian server? SVG to PNG conversion method in Linux environment How to add a new disk to an existing Linux server File copy/move method with progress bar in Linux Hong Kong Server hardware network topology and bandwidth management Discard weak Hash algorithm to ensure SSL/TLS certificate security Method to ensure SSL/TLS certificate security
Go back

24/7/365 support.We work when you work

Support