Force yum update Command To Exclude Certain Packages

See all Redhat/CentOS/Fedora Core related FAQ
How can I exclude selected packages when I rum yum update command under CentOS / RHEL / Fedora / Red Hat Enterprise Linux server?

Yum uses a configuration file at /etc/yum/yum.conf or /etc/yum.conf. You need to place exclude directive to define list of packages to exclude from updates or installs. This should be a space separated list. Shell globs using wildcards * and ?) are allowed.
Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements Linux terminal
Category Package Manager
OS compatibility CentOS RHEL
Est. reading time 2 minutes

How do I exclude php and kernel packages when I use “yum update”?

Open the /etc/yum.conf file, enter:
# vi /etc/yum.conf
Append the following line under [main] section to exclude all php and kernel packages from yum update, enter:

exclude=php* kernel* 

At the end, it should look like as follows:

exclude=php* kernel*
# Note: yum-RHN-plugin doesn't honor this.
# Default.
# installonly_limit = 3
# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d

Save and close the file. You can now use the yum command as usual but certain package will not install.

How Do I Disable Excludes?

You can use the following syntax for yum command (also works with the dnf command):
# yum --disableexcludes=all update
# yum --disableexcludes=main install php
# yum --disableexcludes=repoid install php httpd


  1. all : Disable all excludes
  2. main : Disable excludes defined in [main] in yum.conf
  3. repoid : Disable excludes defined for given repo id

Trying out the yum --exclude Command Line Option

Finally, you can skip yum command updates on command line itself using following syntax:
# yum --exclude=package\* update
# yum --exclude=php\* update
# yum --exclude=kernel\* update
# yum -x 'kernel*' -x 'php*' update

Note: The above syntax will exclude a specific package by name or glob from updates on all repositories.

Recommend readings:

For more information view the manual page on yum command using the following man command:
$ man yum
$ man yum.conf
$ yum --help | grep -Ew -- 'exclude|x'

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

12 comments… add one
  • Hybrid Cloud Apr 18, 2013 @ 14:31

    You should use following php option instead:

    yum --skip-broken install php*
  • higkoo Jan 8, 2014 @ 7:54

    How to use yum to install via version package ?

    There are Nginx-1.5.0 and Nginx-1.5.1 .
    It will install 1.5.1 by default , but I want install 1.5.0 .

    What can I do ?

Leave a Reply

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

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.