How to Check Linux Kernel Version

Written by: Linuxopsys   |   Last updated: June 15, 2022

Kernel is one of the most significant components of the Linux operating system. The kernel is used to manage resources, processes, and provides methods for hardware and software communication. It is important to know the exact Linux Kernel version to install correct software packages, bug fixes, and patches.

In this tutorial, we will discuss different methods to check a Linux kernel version, and explain what each number in the version string means.

What is Kernel Version

The kernel is the control center of your Linux operating system, which ensures operating system security and stability. All Linux operating systems and their distributions may have a different Kernel version.

An updated kernel is required for a secure and stable Linux system. You must also know the Linux kernel version when debugging hardware or software issues, installing new packages, installing bug fixes, or applying patches.

Open the terminal and run the following command:

uname -r
Display Linux kernel version

Kernel Version Format

Each number in the Kernel version string is separated either by a dot or a hyphen.

Let’s understand what these numbers mean:

  • 5 - First number is the main version.
  • 13 - Second number is the major revision.
  • 0 - Third number is the minor revision.
  • 27 - Fourth number is the patch and bug fixes level.
  • generic - This string could be different for each Linux distribution. We are using Ubuntu distribution desktop version, and thus it is showing generic. This could also be the machine architecture, such as x86_64.

The Linux Kernel versions must always match exactly with the supported version before you perform any updates, debugs, installs, or diagnoses on your Linux system.

Commands to Check Kernel Version Linux

The Linux operating system comes equipped with various commands to display Kernel versions. The output of all these commands is different. Some of these commands provide only the kernel version, whereas others provide more detailed system information.

You can check the Linux kernel version using the following commands.

CommandDescription
uname -rDisplays only the Kernel version.
cat /proc/versionDisplays Kernel version along with Kernel build and compile date.
hostnamectl | grep KernelDisplays Kernel version along with Linux version, kernel name, system hostname, computer name, and CPU architecture.
dmesg | grep LinuxDisplays Kernel version along with other system configurations.

Examples to Check Kernel Version in Linux

Your Linux operating system may display the kernel release number in a bit different format. For example, the Red Hat Linux enterprise version shows kernel type and architecture such as el8_2_x86-64 along with the version number.

In the following examples, we will show the different ways to check the kernel version.

uname -r

The uname command with -r option is the commonly used method to find Linux kernel versions.

Use the following command to check the release number of the Linux Kernel:

uname -r
output of uname -r command

You can combine this output with other uname command options, such as -v to display kernel compile date.

cat /proc/version

When your Linux computer starts, a virtual file system proc is created. This file system disappears after you shut down the computer. Linux Kernel information is stored in the /proc/version file, which is used by Linux at runtime. Use the cat command line utility to print version information from this file:

cat /proc/version
output of cat /proc/version

From the output, we can see the version of Linux Kernel along with Linux version, version of gcc used to compile, time of kernel compilation, and username of the person who compiled.

hostnamectl | grep Kernel

The hostnamectl command is primarily used to display and change the hostname of your Linux computer. However, you can also use this command to display the Kernel release number:

hostnamectl | grep Kernel
using hostnamectl to check kernel version

In this example, we can see the hostnamectl command can be used with the grep command, or without the grep command. When used without the grep command, it also shows static hostname, VM machine ID, boot ID, OS distribution, and other system information.

dmesg | grep Linux

The dmesg command line utility is primarily used to print Kernel messages and read device driver messages.

Use the following command to filter kernel version from dmesg output:

dmesg | grep Linux
dmesg showing kernel version

Conclusion

In this tutorial, we learned how to check the Linux Kernel version using different commands.

These commands to check Kernel version works on all Linux distributions, including Ubuntu desktop, Ubuntu server, Red Hat, Debian, and Fedora.

SHARE

Comments

Please add comments below to provide the author your ideas, appreciation and feedback.

Leave a Reply

Leave a Comment