How to Get the Kernel Version in Linux

linux get kernel version

As a Linux user or administrator, you may need to know the version of your kernel at some point. The Linux kernel is the core component of the operating system that interacts with the hardware and manages system resources. Knowing the kernel version is useful when troubleshooting issues, checking compatibility with software or hardware, and updating the system.

In this article, we will explain how to get the kernel version in Linux using various methods. We will also cover related concepts and methods that may help clarify the topic.

Method 1: Using the uname Command

The easiest and quickest way to get the kernel version in Linux is to use the uname command. This command displays various system information, including the kernel version.

To use the uname command, open a terminal and run the following command:

uname -r

This will display the kernel version in the format x.y.z, where x is the major version, y is the minor version, and z is the patch level.

For example, if you run the uname -r command on a system with kernel version 5.4.0-84-generic, the output will be:

5.4.0-84-generic

Method 2: Checking the /proc/version File

Another way to check the kernel version in Linux is to read the /proc/version file. This file contains the kernel version, build date, and other information.

To check the kernel version using the /proc/version file, open a terminal and run the following command:

cat /proc/version

This will display the kernel version along with other information in the format:

Linux version x.y.z-<build-number>-<distro> (<email-id>) (gcc version <gcc-version>) #1 SMP <date> <time> <timezone>

For example, if you run the cat /proc/version command on a system with kernel version 5.4.0-84-generic, the output will be:

Linux version 5.4.0-84-generic (buildd@lgw01-amd64-036) (gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)) #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021

Method 3: Using the /etc/os-release File

The /etc/os-release file contains information about the operating system and distribution. It also includes the kernel version.

To check the kernel version using the /etc/os-release file, open a terminal and run the following command:

grep VERSION /etc/os-release

This will display the version information in the format:

VERSION="x.y (distro)"
VERSION_ID="x.y"

For example, if you run the grep VERSION /etc/os-release command on a system with kernel version 5.4.0-84-generic, the output will be:

VERSION="20.04.3 LTS (Focal Fossa)"
VERSION_ID="20.04"

Method 4: Using the lsb_release Command

The lsb_release command displays LSB (Linux Standard Base) information about the system, including the distribution and release version.

To check the kernel version using the lsb_release command, open a terminal and run the following command:

lsb_release -r

This will display the release version in the format:

Release: x.y.z

For example, if you run the lsb_release -r command on a system with kernel version 5.4.0-84-generic, the output will be:

Release: 20.04

Conclusion

In conclusion, there are several ways to get the kernel version in Linux, including using the uname command, checking the /proc/version file, using the /etc/os-release file, and using the lsb_release command. Each method has its advantages and disadvantages, depending on your needs.

Knowing the kernel version is essential for troubleshooting issues, checking compatibility with software or hardware, and updating the system. We hope this article has helped you understand how to get the kernel version in Linux and related concepts and methods.