check kernel version on the server

How to check kernel version on the server?

Today we will tell you how to check a kernel version? We’ll show you what the kernel is and how to prevent it and ensure it’s up to date, but first let’s answer common questions when in a Linux environment or even a computer environment. Know we will know what is a kernel.

What is a Kernel?

The Linux kernel is the most essential part at the heart of an operating system, think of it as the brain of the entire operation. The kernel manages the operation of two primary components: memory and CPU time. It does this by processing internal communication between hardware and software. Which is performed through the use of system calls.

There is no good example for this. Your typical user will never interact with the kernel because the functions it performs are behind the scenes and not visible in their day-to-day operations.

 

Kernel Layout

Overall, there are three generic kernels available that you see in everyday systems, they are:

  • Microkernel – Designed to contain only basic functionality. (multitasking, memory management, etc.)
  • Monolithic kernel – designed to contain many device-related drivers to manage multiple system functions. (eg Linux)
  • Hybrid Kernel – Aggregate design of both micro and monolithic kernels. It was developed with performance in mind. (eg Windows)

With this in mind, most Linux operating systems are not based on a proprietary kernel.

Now you can proceed to check/update and/or remove different Linux kernel versions.

Check kernel version

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

# uname -rv

3.10.0-693.11.6.el7.x86_64 #1 SMP Wed Feb 4 02:07:27 UTC 2022

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

If you’re running a VPS (virtual private server) as an OpenVZ container, you’ll see “stab” in the kernel version:

# uname -r
2.6.32-042stab125.5

If you’re running CentOS 7 on a dedicated server or a KVM virtual server, you’ll 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’re running CloudLinux, you can see “lve” in the kernel version:

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

You can also check the following yum command:

yum info kernel -q

This command can be noticeably longer because yum is a Python interpreter and uses one or more plugins by default. However, it gives more detailed information. This will usually only show the last installed kernel and not the current running kernel.

Here is a sample 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 root of any
: Linux operating system. The kernel handles the basic functions
: Operating system: memory allocations, process allocations, devices
: input and output, etc.

Linux Kernel Upgrading

If you have a VPS as an OpenVZ container, it is not possible to upgrade your kernel independently, as all virtual containers are loaded on the node running the same kernel. Therefore, voluntary upgrades can only be done on dedicated servers and KVM-based virtual servers.

To upgrade a kernel, you can run this yum command: “upgrade yum kernel”.

By default, this command should ask for confirmation to install the new kernel: “Is this ok [y/d/N]:”.

If you want to skip confirmation, you can use the -y switch (however, it is not recommended to skip confirmation unnecessarily, especially for major changes like new kernels, since these should not be done accidentally): “yum upgrade kernel -y”.

When the new kernel is installed you need to load it. To do this, you need to reboot the server: “reboot”.

When the server is finished rebooting, you should load the kernel version described in the previous section.

Usage Of KernelCare

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

You can find 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 the patch has been applied, run: “kcarectl –info”

How to remove Kernel old version

Sometimes you may need to manually remove old kernels from the server. To check all installed kernels, this yum command can 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 package-cleanup command with the -old kernels switch will remove all old kernels, leaving only the ‘count’ most recent ones (by default number = 2). For example, to remove all but the most recently installed and loaded kernels, run the following command: “package-cleanup –oldkernels –count=1”.

Conclusion

Making sure your server is running the correct kernel will go a long way in terms of the stability and performance of how the system works. Kernel patches occur frequently and help ensure a stable environment while protecting your system from the latest kernel-level vulnerabilities.

Oudel Inc. Offers best-in-class technical support 365 days a year, 24 hours a day, 7 days a week. A dedicated team is ready to help you update your kernel or general queries related to it if you need our help. If you want to know how to remove malware from your website then you can read this article.

Scroll to Top