Force yum update Command To Exclude Certain Packages

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.

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

Open /etc/yum.conf file, enter:
# vi /etc/yum.conf
Append the following line under [main] section, 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:

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

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 command:
$ man yum
$ man yum.conf

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 12 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
12 comments… add one
  • Ben Jun 17, 2008 @ 13:45

    Is there some way to override exclusions configured in the conf file when yum is run manually, short of removing or commenting the exclude entry in the conf files?

    Say I’d like to automate the updates of most of my packages, but some subset of core packages I’d like to upgrade manually after I’ve had a chance to test the package.

  • Raj Jun 17, 2008 @ 16:49


    I’m afraid but it is not possible to achieve.

  • Bob Aug 28, 2008 @ 19:30

    I’m not sure what version of yum they added this, but:
    `yum –disableexcludes=[all|main|repoid]`
    `yum –disableexcludes=all update`
    `yum –disableexcludes=all update kernel`

  • Christian Peper Oct 29, 2008 @ 15:45

    Just a note, the switch -disableexcludes=all does no work on my RHEL 4u5 server.

    Using yum-2.4.2-4…

  • Matt Schreiner Jul 3, 2009 @ 16:24

    YUM version 3.2.19 in my REHL 5U3 box does have support for -disableexcludes

    [root@cerberus etc]# yum –version

    [root@cerberus etc]# man yum |grep -A4 -B1 excludes
    Disable the excludes defined in your config files. Takes one of
    three options:
    all == disable all excludes
    main == disable excludes defined in [main] in yum.conf
    repoid == disable excludes defined for that repo

    Might just try to update your YUM package and see if there is a 3.x package avail for REHL4 now and if not try to just install from source…

  • Bhavya Sep 30, 2009 @ 7:18

    Hi friends,
    When I tried to run the cellsdkiso install or any of the yum commands i am getting this error please let me know what might have gone wrong for this.
    I am Installing the IBM Cell SDK into fedora 9.
    Config Error: Parsing file failed: File contains no section headers.
    file: file:///etc/yum.conf, line: 1
    Please See My Yum file below
    exclude=blas blas-devel elfspe2 kernel lapack lapack-devel libspe2 libspe2-debuginfo libspe2-devel oprofile oprofile-devel

    # PUT YOUR REPOS HERE OR IN separate files named file.repo
    # in /etc/yum.repos.d

    Thanks & regards

  • Nov 28, 2009 @ 13:22

    One of the best sites devoted to practical programming.
    thanks from newbie @nixCraft :)

  • Simon Smith Jan 4, 2010 @ 18:15

    Thank you for this post!


  • CentOS Jan 16, 2010 @ 0:02

    Excluding httpd (apache) in CentOs:

    yum –exclude=httpd*,httpd-manual*,mod_ssl* update

    PS. httpd-manual and mod_ssl are htpd dependencies.

  • Eduardo Mozart de Oliveira Jan 30, 2013 @ 23:07

    Thank you! I do not want that CentOS 5.8 automatically updates to 5.9 (Hyper-V Add-ons was not updates to 5.9 yet).
    Adding “centos-release*” (without quotes) on /etc/yun.conf resolved my problem!

  • 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.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum