HowTo: Prevent Yum From Upgrading The Kernel On a CentOS / Red Hat Enterprise Linux

in Categories , , last updated February 19, 2014

I am a new RHEL / Centos Linux server admin. I would like yum to update all packages except the Linux Kernel. How can I prevent yum command from updating kernel on a CentOS/RHEL/Fedora Linux based systems?

You can prevent yum command from updating the Kernel permanently by following the simple steps.

Option #1: Edit /etc/yum.conf file

Use a text editor such as vi to edit /etc/yum.conf:
# vi /etc/yum.conf

Append/modify exclude directive line under [main] section, enter:
Save and close the file. Try, updating the system without updating the Linux kernel:
# yum -y update
This is a permanent option, so you don’t need pass the -x option to yum command.

Option #2: Pass the -x option to prevent yum from updating kernel

The syntax is as follows to skip update on command line itself:
# yum -x 'kernel*' update

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

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

6 comment

  1. The title is misleading.Should be more like
    How to prevent Yum from Upgrading the kernel on a CentOS / Red Hat Enterprise Linux

  2. Appreciated alot! This solved my problem with virtual machine wanting to upgrade kernel (and by that also uninstall bunch of VM addons… => crashing my system). Now I keep my kernel at stable version without having issues with upgrades. I can upgrade everything else.

  3. Hello,
    Thanks for the article,
    I would also add to the /etc/yum.conf exclude statement redhat-release* for Red Hat Linux servers in the event you don’t want it to move up your release.
    exclude=kernel* redhat-release*

    Sometimes we don’t want to patch kernel as well as your current Red Hat version. Also there might be some application requirements that will force you to stick to a certain version of the OS.

    Have a question? Post it on our forum!