How to know which Linux Kernel Version is installed in my System

  • Post last modified:January 28, 2022
  • Reading time:8 mins read
  • Post author:
  • Post comments:0 Comments

There are a couple of reasons why you should know your Linux kernel version, It could be a handful when you want to install the Linux header, and even it’s a pretty common error for the VMware Workstation to fail in case of a missing Linux header.

In this article, you will see how to check the kernel version, alongside you will see the steps to install Linux header on your system.

Check Kernel Version in Linux

If you are in a hurry to know the kernel version, please use the following command, and we will later explain to you what command output means.

  • uname -r: get Linux kernel version
  • hostnamectl: get Linux kernel with a bunch of extra details like machine id, hostname, etc.
  • cat /proc/version: show kernel along with build-essentials versions.
  • sudo dmesg | grep -e ‘Linux version’: use kernel ring buffer to check kernel version with grep command.

Find kernel version using uname -r

The uname command is one of the most useful commands to check the kernel version. The reason why I’m emphasizing uname is because it shows you the exact kernel version without any extra details.

$ uname -r

I believe you can see the output on your screen but are not able to intercept what the kernel version means. Let me extract the information for you. Under my hood, the system is running with 5.10.0-11-amd64.

5.10.0-11-amd64
Find kernel version using uname -r
Find kernel version using uname -r
  • 5 : Main kernel version
  • 10 : Major kernel revision
  • 0 : Minor kernel revision
  • 11 : Level of patches or bug fixes
  • amd64 : It’s related to architecture,kernel info

I hope you were able to get the kernel version information. Later, you will see how to use the uname command to download Linux headers.

Find kernel version using hostnamectl

This command is not limited to checking the kernel version. You can set temporary hostname too, if you are interested to know check How to set or change the temporary hostname in Linux.

To get the kernel version with extra information type hostnamectl.

$ hostnamectl

If you are peculiar with the kernel version use the grep command.

$ hostnamectl | grep Kernel
Find kernel version using hostnamectl
Find kernel version using hostnamectl

Find kernel version using cat /proc/version

To get information about kernel version you can use /proc/version. As you know /proc is a virtual filesystem that stores information about the running system.

Although you can use cat, more or less command to read information. For example, you can get the content of /proc/version with the below command.

$ cat /proc/version

The output result includes the kernel version along with the development tools version.

Find kernel version using cat /proc/version
Find kernel version using cat /proc/version

Find kernel version using dmesg

You may have seen a number of lines dynamically printed on your screen when your system gets powered on, right? This printed message is called a “dmesg,” which stands for diagnostic message, or some say display message.

This is a very important file thats tells you about system errors and various other information in a human-readable format.

A dmesg requires sudo access to print data along with grep to filter out the kernel version.

To get the kernel version, do copy and paste the below command.

$ sudo dmesg | grep 'Linux'

Find kernel version using dmesg
Find kernel version using dmesg

Download Linux Header

As mentioned, we can use uname to download Linux headers. To download Linux headers for the current version, use the below command.

$ sudo apt install linux-headers-$(uname -r)

Download Linux Header

 

Download Linux Header

Recently, the 5.16 kernel was released. Check this article to upgrade your system’s kernel version. How to Upgrade the Linux Kernel to the 5.16 Release.

Wrap up

The steps to check the kernel version are pretty simple. We have enlisted four different ways to check the Linux kernel version in Linux distributions.

All the listed commands will work on all platforms.

That’s all for now!

Leave a Reply