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?

[donotprint]
Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements None
Est. reading time 2m
[/donotprint]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:
exclude=kernel*
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


🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 6 comments so far... add one


CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
6 comments… add one
  • benjamin Feb 19, 2014 @ 9:30

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

    • 🐧 Nix Craft Feb 19, 2014 @ 10:21

      Done. I appreciate your feedback and post :)

  • benjamin Feb 19, 2014 @ 10:29

    Welcome :)

  • Nikhil Feb 21, 2014 @ 5:13

    Cool stuff :)

  • Riot77 Feb 24, 2014 @ 10:50

    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.

  • Franklyn Mendez Mar 3, 2014 @ 14:14

    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.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum