Three ways to exclude a specific package from yum update

As part of system update, you may need to exclude few of the packages due to application dependency in Red Hat based system.

If so, how to exclude and what are all the ways to do that?

It can be done in three ways, we will see all those methods in this article.

A package manager is a collection of tools that allow users to easily manage packages in Linux system.

It allows users to install, update/upgrade, remove, query, re-install, and search packages in Linux system.

For Red Hat and it’s clone, we uses yum Package Manager and rpm Package Manager for package management.

What’s yum?

yum stands for “Yellow dog Updater, Modified”. Yum is an automatic updater and package installer/uninstaller for rpm systems.

It automatically resolve dependencies while installing the package.

What’s rpm?

rpm stands for “Red Hat Package Manager” and it is a powerful package management tool for Red Hat system.

The name RPM refers to .rpm file format that containing compiled software’s and necessary libraries for the package.

You may be interested to read the following articles, which is related to this topic. If so, navigate to appropriate links.

Method 1 : Exclude Packages with yum Command Manually or Temporarily

We can use --exclude or -x switch with yum command to exclude specific packages from getting updated through yum command.

This is a temporary method or On-Demand method. If you want to exclude specific package only once then we can use this method.

The below command will update all packages except kernel.

To exclude single package.

# yum update --exclude=kernel


# yum update -x 'kernel'

To exclude multiple packages. The below command will update all packages except kernel and php.

# yum update --exclude=kernel* --exclude=php*


# yum update --exclude httpd,php

Method-2: Exclude Packages with yum Command Permanently

If you are frequently performing the patch update,You can use this permanent method.

To do so, add the required packages in /etc/yum.conf to disable packages updates permanently.

Once you add an entry, you don’t need to specify these package each time you run yum update command. Also, this prevents packages from any accidental update.

# vi /etc/yum.conf


cachedir=/var/cache/yum/$basearch/$releasever keepcache=0 debuglevel=2 logfile=/var/log/yum.log exactarch=1 obsoletes=1 gpgcheck=1 plugins=1 installonly_limit=3 exclude=kernel* php*

Method-3: Exclude Packages Using Yum versionlock plugin

This is also permanent method similar to above. Yum versionlock plugin allow users to lock specified packages from being updated through yum command.

To do so, run the following command. The below command will exclude the freetype package from yum update.

You can also add the package entry directly in “/etc/yum/pluginconf.d/versionlock.list” file.

# yum versionlock add freetype

Loaded plugins: changelog, package_upload, product-id, search-disabled-repos, subscription-manager, verify, versionlock
Adding versionlock on: 0:freetype-2.8-12.el7
versionlock added: 1

Use the below command to check the list of packages locked by versionlock plugin.

# yum versionlock list

Loaded plugins: changelog, package_upload, product-id, search-disabled-repos, subscription-manager, verify, versionlock
versionlock list done

Run the following command to discards the list.

# yum versionlock clear

About Magesh Maruthamuthu

Love to play with all Linux distribution

View all posts by Magesh Maruthamuthu

Leave a Reply

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