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

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
Difficulty Easy (rss)
Root privileges Yes
Requirements yum
Time 5m
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.

ADVERTISEMENTS

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
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig 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 jobs killall kill pidof pstree pwdx time
Searchinggrep 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

ADVERTISEMENTS
4 comments… add one
  • Chris Jan 6, 2014 @ 12:34

    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.

  • city classifieds Feb 11, 2015 @ 19:17

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

  • ASHWINII Feb 18, 2016 @ 14:42

    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

  • Sandy Apr 20, 2017 @ 12:19

    I tried this on a vm, unfortunately the kernel was still updated anyway.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.