A Web.com Partner

YUM Update: How to Exclude Packages

Sometimes when running a ‘yum update’ there are certain packages you may be running which you wish to remain static, or which can potentially cause errors with running a ‘yum update’. In these situations it is useful to force yum to exclude certain packages from being updated under CentOS.

Yum uses a configuration file located at /etc/yum/yum.conf or /etc/yum.conftux-small

If you wish to exclude packages you need to define a list for exclusion 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:
# vi /etc/yum.conf

Append following line under [main] section, enter:

exclude=php* kernel*

At the end, it should look like as follows:

[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
exclude=php* kernel*

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

# Default.
# installonly_limit = 3

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
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

x