Making dnf/yum Not Update Certain Packages

We may not want to update some packages such the kernel on a stable server while updating the system. If we run “dnf update” or “yum update”, we may get suggested by dnf/yum to install all the packages with updates.

In this post, how to make dnf/yum not update certain packages such the kernel when updating system will be introduced.

Method making dnf/yum not update certain packages

The method is simple. Add this line to dnf or yum’s configuration file:

exclude=package_names package_name_pattern

For example, to exclude package kernel, nss and nss- from being updated, the line will be:

exclude=kernel* nss nss-*

Package names are separated by a space. Shell globs using wildcards (eg. * and ?) are allowed.

The configuration file for dnf/yum

The configuration file for dnf and yum are different. For newer systems like Fedora 22+, the dnf one will be used unless you install the yum-obsoleted package.

For dnf, the configuration file is located under:


For yum, the configuration file is located under:


Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.


  1. Thank you for sharing, this is useful for now, as I need to whitelist libreswan upgrade because broken version check…

Leave a Reply

Your email address will not be published. Required fields are marked *