Exclude a package from yum update

# vi /etc/yum.conf

append the following line:
exclude=sendmail kernel*

e.g.
[main]
cachedir=/var/cache/yum
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
distroverpkg=redhat-release
tolerant=1
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
bugtracker_url=http://bugs.centos.org/yum5bug
exclude=sendmail dkim*

# Note: yum-RHN-plugin doesn’t honor this.
metadata_expire=1h

installonly_limit = 5

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

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

Where,

all : Disable all excludes
main : Disable excludes defined in [main] in yum.conf
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.

Leave a Reply

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

12 − eight =