Open In App

How to Check Kernel Version in Linux

Last Updated : 16 Jan, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

The kernel in the Linux Operating System is the core brain component of OS. Kernel in Linux OS is mainly a bridge between the hardware and the software layers. All the necessary services and the functionalities of the OS and the application are been provided by Kernel. The kernel has its version which differs according to the system. Knowing this version of the Kernel can be important when we need to perform the troubleshooting of our system hardware or in the scenario of system maintenance.

There is the standard format of kernel which is represented in the form of “a.b.c“. Each numerical has its specification which is stated below:

  • Major Version (a): The major version of Kernel describes the important updates and changes to the Kernel. All the architectural changes, newly added features, etc. are represented using the Major Version.
  • Minor Version (b): The minor version of the Kernel describes or presents the smaller updates, recent bug fixes, and some potential feature improvements in the major version. All the minor versions are created to be reversed compatible, in summary, minor versions can be applied to the same major version without introducing any problems.
  • Patch Level (c): The patch level of the Kernel describes the incremental updates and some bug fixes that are associated with the above minor version. Patch level is associated with resolving software bugs, addressing security flaws, etc. These are reversed and compatible with the same major and minor versions without introducing any issues with the compatibility.

How to Check Kernel Version in Linux?

To check the Kernel Version in Linux, we have different types of ways and methods that will help us to get the kernel version of the system. Below are the ways through which we can get the kernel version:

So, we will get the version of the kernel by using all these above-specified methods:

How to Check Kernel Version Using uname Command in Linux

We can check the version of the kernel using the uname command. uname (Unix Name) is used to display the system information. To get the specific kernel version we can use the ‘r’ flag along with the command. So execute the below command in the terminal to get the version of the Kernel

uname -r



Output:

Checking Kernel Version using uname command

Checking Kernel Version using uname command

From the above screenshot:

  • 5: This is the Major Version
  • 18: This is the Minor Version
  • 0: This is the Patch Level
  • kali5-amd64: This is the Distribution Name

How to Check Kernel Version Using hostnamectl Command in Linux

In this method, we will be checking the Kernel Version using hostnamectl command. hostnamectl command in Linux is used to display the system config information. It also displays the kernel version. So use the below command in the terminal to get the kernel version.

hostnamectl 



Output:

Checking Kernel Version using hostnamectl command

Checking Kernel Version using hostnamectl command

How to Check Kernel Version by viewing /proc/version File in Linux

In this method, rather than using the inbuilt command, we will check the version by viewing the contents of the /proc/version file. This file has various information about the system like compiler details, kernel version, build information, etc. We just need to view the file using the cat command or else we can also use the various text editors like vi, and vim to view the file. Run the below command in the terminal to check the version.

cat /proc/version



Output:

Checking Kernel Version by viewing /proc/version file

Checking Kernel Version by viewing /proc/version file

How to Check Kernel Version Using dmesg Command in Linux

In this method, we will be using the dmesg command to get the kernel version. dmesg command in Linux is used to display the kernel messages that are created during the booting process of the system. So from these messages, we can check the kernel version. Execute the below command in the terminal.

sudo dmesg | grep Linux



Output:

Checking Kernel Version using dmseg command

Checking Kernel Version using dmseg command

How to Check Kernel Version Using the dpkg Command in Linux

In this method, we will be using the built-in dpkg command to check the kernel version. Using the -l flag with the command, we can get the information about the list of installed packages and also the kernel version. We need to pipe the output by using the grep command.

dpkg -l | grep linux-image



Output:

Checking Kernel Version using dpkg command

Checking Kernel Version using the dpkg command

How to Check Kernel Version Using the ls Command for Kernel Images in Linux

In this method, we will check the kernel version using the inbuilt ls command. We need to use the ls command in the /boot directory to list the installed kernel images then we can identify the versions easily. Execute the below command in the terminal to get the kernel version.

ls /boot/vmlinuz-*


Output:

Checking Kernel Version using ls command

Checking Kernel Version using ls command

Conclusion

In conclusion, knowing the kernel version is an essential task while working in a Linux environment, as this can help many administrators troubleshoot system issues. Many methods can be used to check the version of the kernel in Linux. By using inbuilt commands like dmesg, hostnamectl, uname it is easy to check the kernel version, but also, there are some configuration files that stores the information of the kernel. So by checking the contents of the files, we can easily retrieve the kernel version of our Linux system.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads