Linux Commands

How to Check Kernel Version in Linux

The kernel acts as a core component and heart of all Linux systems. It works as the connection between software and hardware while managing all system resources. Kernel is essential in driver updates, security updates, bug fixes, system maintenance, documentation, and other system diagnostics. Eventually, it ensures a proper device management, overall security, and optimal PC performance.

Moreover, Linux administrators and other users must know their kernel version to determine the system’s software and hardware compatibility. However, beginners don’t know how to find and check the kernel version. Hence, in this short guide, you will get to know about the ways to check the kernel version in any Linux system.

How to Check Kernel Version in Linux

The format of the kernel version is a.b.c-d. For instance, 6.2.0-37, where a, b, c, and d are the kernel version, its major revision, minor revision, and patch number, respectively. Checking the kernel version is easy; you can use a few methods for it. Let’s take a look at them all.

1. Using the Uname Command (Easiest Method)
The uname (UNIX name) command is a powerful utility with critical information about your Linux operating system. To display the kernel release, use the syntax as follows:

uname -r

The “-r” option, when used with the “uname” command, displays the kernel release.

2. Combining Dmesg and Grep Commands
Kernel displays some messages during the boot process of your Linux operating system. The “dmesg” command recalls those messages and displays them again in the command line. Meanwhile, the “grep” command searches for a specific text in any file or process. By combining both commands, we can specifically check for the kernel version.

sudo dmesg | grep "Linux"

Here, the “Linux version 6.2.0-39-generic” is the kernel version. The previous command pipelines the messages that are received from the “dmesg” command into the “grep” command to search for the term “Linux”.

3. Reading the Version File
Linux stores a crucial information about its kernel, such as its version and distribution number, in the “/proc/version” file. You can access this file to know your kernel version through the following command:

cat /proc/version

Note that you must use this command in the home directory. Upon entering it, it yields the following result:

4. Using the Hostnamectl Command
The “hostnamectl” command displays the hostname and other information in a Linux device. However, you need to use it with the “grep” command to find the kernel version.

hostnamectl | grep Kernel

Conclusion

Checking the kernel version is a fundamental task of every Linux user and system administrator. However, due to the less understanding of some commands, the users cannot find it. Hence, we explained the four simple methods to check the kernel version in Linux. While the “uname” command is the easiest, all other mentioned methods will get your job done effortlessly.

About the author

Prateek Jangid

A passionate Linux user for personal and professional reasons, always exploring what is new in the world of Linux and sharing with my readers.