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

Posted on in Categories , , , last updated November 11, 2013

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?

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

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

4 comment

Leave a Comment