KNOWNHOST KNOWLEDGE BASE

Hosting Question? Find the Solution - Browse our Guides, Articles, and How-To's

How do I check the kernel version on my server?

In this article, we’re going to go over Linux kernels. We’ll show you what a kernel is and how to go about checking it and ensuring it’s up to date, but first let’s answer the common question when within a Linux environment or even any computer environment.

What is a Kernel?

The Linux Kernel is the center most important part of an operating system, think of it as the brain of the whole operation. The kernel handles the operations of two primary components: memory and CPU time. It does this by processing the internal communication between the hardware and the software, this is performed through the use of system calls.

There’s no good example for this — your typical user won’t ever interact with the kernel as the functions it performs are behind the scenes and not visible in their daily operations.

how a kernel works

Showing the jobs of a kernel within a computer

Overall, there are three generic kernels available that you see in day-to-day systems, they are:

  • Microkernel — Designed to only contain basic functionality. (multitasking, memory administration, etc)
  • Monolithic Kernel — Designed to contain many device related drivers to handle multiple system functionality. (Ex. Linux)
  • Hybrid Kernel — Aggregated design of both micro and monolithic kernels. This was built with performance in mind. (Ex. Windows)

With that in mind, most if not all Linux Operating systems are based off a monolithic kernel.

Now you can move on to checking/updating and/or removing the various Linux kernel versions.

Checking the Kernel Version

To check system parameters such as the kernel version and build date, OS architecture, hostname, etc., you can use the uname command, which is included in coreutils package:

  # uname -rv
  3.10.0-693.11.6.el7.x86_64 #1 SMP Thu Jan 4 01:06:37 UTC 2018

To view the current kernel version and build date, run uname -r. Depending on the platform your server is running on, you may see slightly different output, even for the same CentOS 7 operating system.

If you run a VPS (Virtual Private Server) as an OpenVZ container, you will see the “stab” in the kernel version:

  # uname -r
  2.6.32-042stab125.5

If you run CentOS 7 on a Dedicated Server or a KVM virtual server, you could see “el7” in the kernel version, which refers to Red Hat Enterprise Linux, from which CentOS is derived:

  # uname -r
  3.10.0-693.11.6.el7.x86_64

If you are running CloudLinux, you could see “lve” in the kernel version:

  # uname -r
  3.10.0-714.10.2.lve1.5.9.el7.x86_64

Another way to check would be with the following yum command:

  yum info kernel -q

This command may run noticeably longer, because yum uses a python interpreter and one or more plugins by default. However, it gives more detailed information. This will usually only show the latest installed kernel and not the current running kernel.

Here is an example of possible output from this command:

  # yum info kernel -q
  Available Packages
  Name        : kernel
  Arch        : x86_64
  Version     : 3.10.0
  Release     : 693.11.6.el7
  Size        : 43 M
  Repo        : updates/7/x86_64
  Summary     : The Linux kernel
  URL         : http://www.kernel.org/
  License     : GPLv2
  Description : The kernel package contains the Linux kernel (vmlinuz), the core of any
              : Linux operating system.  The kernel handles the basic functions
              : of the operating system: memory allocation, process allocation, device
              : input and output, etc.

Upgrading the Linux Kernel

If you have a VPS as an OpenVZ container, it is not possible to upgrade your kernel independently, because all virtual containers run the same kernel loaded on the node. Therefore, voluntary upgrade can be performed only on Dedicated Servers and KVM-based virtual servers.

To upgrade the kernel, you can run this yum command:

  yum upgrade kernel

By default, this command should ask for confirmation to install new kernel:

  Is this ok [y/d/N]:

If you want to skip the confirmation, you can use the -y switch (However, it is not recommended to skip confirmations unnecessarily, especially for big changes like new kernels, since these especially should not be performed accidentally):

  yum upgrade kernel -y

Once the new kernel is installed you need to load it. To do so, you need to reboot the server:

  reboot

Once the server has finished rebooting, you should check the loaded kernel version as described in previous section.

KernelCare Usage

KernelCare is a live-patching software for Linux kernels distributed by CloudLinux. When using KernelCare, the server does not require rebooting for kernel upgrades, and kernel patches are checked and applied on the fly automatically every 4 hours. It is available only for Dedicated Servers and KVM virtual servers.

You can check if KernelCare is installed as follows:

  # yum info kernelcare -q
  Installed Packages
  Name        : kernelcare
  Arch        : x86_64
  Version     : 2.14
  Release     : 2
  Size        : 217 k
  Repo        : installed
  From repo   : kernelcare
  Summary     : KernelCare tools
  URL         : http://www.cloudlinux.com
  License     : CLOUD LINUX LICENSE AGREEMENT
  Description : KernelCare userland tools

To check if patches have been applied, run:

  kcarectl --info

More details about KernelCare can be found in the following places:

Removing the Old Kernel Version.

Sometimes you may need to remove old kernels from the server manually. To check all installed kernels, this yum command could be used again:

  # yum list kernel -q
  Installed Packages
  kernel.x86_64            3.10.0-693.11.1.el7           @updates
  kernel.x86_64            3.10.0-693.11.6.el7           @updates

Using the command package-cleanup with the --oldkernels switch would remove all old kernels, leaving only ‘count‘ most recent ones (by default count=2). For example, to remove all kernels except the one most recently installed and loaded, run the following command:

  package-cleanup --oldkernels --count=1

Conclusion

Ensuring that the proper kernel is running on your server will go a long way in the stability and performance of how the system operates. Kernel patches occur often and help ensure a stable environment while protecting your system from any recent kernel-level vulnerabilities.

KnownHost offers 365 days a year, 24 hours a day, all 7 days of the week best in class technical support. A dedicated team is ready to help you with updating your kernel or general questions regarding it should you need our assistance. You’re not using KnownHost for the best web hosting experience? Well, why not? Check with our Sales team to see what can KnownHost do for you in improving your web hosting experience.