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

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, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Share this on (or read 4 comments/add one below):

4 comment

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

  2. Thanks it is useful article, I agree with Chris if we do without -y then we can verify the packages.

  3. i need a help. I want to upgrade the packages & kernel in the servers that are running
    Eg: if there are around 200 packages now who to upgrade them at once. kindly reply me

    Have a question? Post it on our forum!