RHEL/CentOS: yum Update All Packages Except the Linux Kernel

by on November 11, 2013 · 1 comment· LAST UPDATED November 11, 2013

in , , ,

I am a new CentOS Linux user running my community site on production server. I want to update all packages except the Linux kernel on CentOS Linux. How can I prevent the yum command from updating the Linux kernel on CentOS/RHEL/Scientific/Fedora Linux server?

Tutorial details
DifficultyEasy (rss)
Root privilegesYes
Requirementsyum
Estimated completion time5m
You can easily run yum update command to updates everything but the kernel using the exclude directive. This option define list of packages to exclude from updates or installs. This should be a space separated list. Shell globs using wildcards * and ?) are allowed.

yum syntax to update all except Kernel

The syntax is:

yum --exclude=packgeName\* update
yum --exclude=packgeName1\* --exclude=packgeName2\* update
yum -x 'packageName*' update
yum -x 'packageName1*' -x 'packageName2*' update

Examples

To prevent yum command from updating the Kernel type:

 
yum -y --exclude=kernel\* update
 

OR

 
yum -y -x 'kernel*' update
 

How do I prevent yum from Updating the Kernel permanently?

Edit /etc/yum.conf file, enter:
# vi /etc/yum.conf
Append/modify exclude directive line under [main] section, enter:

exclude=kernel*

Save and close the file. Now, you can just run the following without passing the -x or --exclude option to yum command:
# yum -y update

See also
TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 1 comment… read it below or add one }

1 Chris January 6, 2014 at 12:34 pm

It suggest leaving out the ‘-y’ option in the example or at least explain its use lest someone expecting to be prompted ends up surprised.

Reply

Leave a Comment

Tagged as: , ,

Previous Faq:

Next Faq: