5 easy & useful ways to check Linux kernel version


Tips and Tricks, Linux

In this tutorial I will share multiple commands and methods you can use to check the Linux kernel version. We know that kernel is the core component in Linux and it is important that you know what version of kernel the system is running.

 

Method 1: Check Linux kernel version using uname

uname is the most handy tool which is used to print the system information.

On RHEL/CentOS/Fedora

In the provided distributions the output of uname would be similar to

 ~]# uname -r
4.18.0-193.14.2.el8_2.x86_64

The output can be broken into below format

<major_version>-<minor_version>-<release>.<architecture>

Here,

  • 4.18.0 is the major version
  • 193.14.2 is the minor version
  • el8_2 is the release
  • x86_64 is the architecture

To list the installed kernel:

 ~]# rpm -q kernel
kernel-4.18.0-80.el8.x86_64
kernel-4.18.0-147.5.1.el8_1.x86_64
kernel-4.18.0-193.14.2.el8_2.x86_64

 

On SLES/OpenSuSE

The output of uname would be different with SLES release which is again the kernel version for SLES platform.

# uname -r
3.0.101-108.81-default

You can use uname -a to get more details on the kernel version, system architecture etc

# uname -a
Linux cc01-nds-ins 3.0.101-108.81-default #1 SMP Fri Nov 2 18:02:20 UTC 2018 (2208a0f) x86_64 x86_64 x86_64 GNU/Linux

To list the installed kernel:

~ # rpm -q kernel-default
kernel-default-3.0.101-108.81.1

 

On Ubuntu/Debian

In the provided distribution, kernel is referred as linux-image. The kernel versions of Ubuntu/Debian are assigned by the respective developers and they don't follow the normal naming syntax or standards.

Output from my Ubuntu server:

# uname -r
5.0.0-23-generic

Here,

  • 5 is the major version
  • 0 from the second field is the minor version
  • 0 from the third field is the patch level
  • 23-generic is the developer patch level and in our context is what is assigned by the Ubuntu developers.

To list the available kernel package, you can use:

:~# dpkg --list | grep linux-image
ii  linux-image-5.0.0-23-generic        5.0.0-23.24~18.04.1       amd64        Signed kernel image generic
ii  linux-image-generic-hwe-18.04       5.0.0.23.80               amd64        Generic Linux kernel image

 

Method 2: Check Linux kernel version using hostnamectl

You may not find this command if you are using older releases. hostnamectl may be used to query and change the system hostname and related settings. But it also prints the kernel information.

The output of this command would be same across all Linux distributions. Below is an output from RHEL 8 server:

5 easy & useful methods to check Linux kernel version
hostnamectl to check Linux kernel version

 

Method 3: Check Linux kernel version using grubby

grubby is only available in RHEL/CentOS/Fedora/SuSE distribution i.e. it is not yet available in Debian/Ubuntu (at the time of writing this article). grubby is a command line tool used to configure bootloader menu entries across multiple architectures.

To list the default kernel version:

~]# grubby --default-kernel
/boot/vmlinuz-4.18.0-193.14.2.el8_2.x86_64

To get more information on this kernel, we can use "grubby --info /boot/vmlinuz-4.18.0-193.14.2.el8_2.x86_64". Following is an output from my server:

5 easy & useful methods to check Linux kernel version
grubby to show Linux kernel version

 

Method 4: Check Linux kernel version using boot log messages

4.1: Using dmesg

In most distributions we use dmesg to access the boot up log messages which also contains the kernel version along with many other details.

Output from RHEL/CentOS/Fedora

~]# dmesg | grep "Linux version"
[ 0.000000] Linux version 4.18.0-193.14.2.el8_2.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 8.3.1 20191121 (Red Hat 8.3.1-5) (GCC)) #1 SMP Sun Jul 26 03:54:29 UTC 2020

 

Output from Ubuntu/Debian

~# dmesg | grep "Linux version"
[    0.000000] Linux version 5.0.0-23-generic (buildd@lgw01-amd64-030) (gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)) #24~18.04.1-Ubuntu SMP Mon Jul 29 16:12:28 UTC 2019 (Ubuntu 5.0.0-23.24~18.04.1-generic 5.0.15)

 

Output from SLES

# dmesg | grep "Linux version"
[    0.000000] Linux version 3.0.101-108.81-default (geeko@buildhost) (gcc version 4.3.4 [gcc-4_3-branch revision 152973] (SUSE Linux) ) #1 SMP Fri Nov 2 18:02:20 UTC 2018 (2208a0f)

 

4.2: Using journalctl

In recent Linux distributions we have journalctl which gives us more flexibility in reading and accessing the log messages. To check the boot up log messsages we use -b switch with journalctl command

Output from RHEL/CentOS/Fedora

~]# journalctl -b | grep "Linux version"
Sep 18 11:50:55 server.example.com kernel: Linux version 4.18.0-193.14.2.el8_2.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 8.3.1 20191121 (Red Hat 8.3.1-5) (GCC)) #1 SMP Sun Jul 26 03:54:29 UTC 2020

 

Output from Ubuntu/Debian

~# journalctl -b | grep "Linux version"
Sep 18 11:50:51 deepak-VirtualBox kernel: Linux version 5.0.0-23-generic (buildd@lgw01-amd64-030) (gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)) #24~18.04.1-Ubuntu SMP Mon Jul 29 16:12:28 UTC 2019 (Ubuntu 5.0.0-23.24~18.04.1-generic 5.0.15)

Currently I don't have access to SLES 12 or higher so I can't post the output but the same command would work with any SLES release higher than SLES 12.

 

Method 5: Check content of /proc/version

The output which you got earlier in Method 4 by grepping "Linux version" from the boot log files is actually collected from /proc/version. So if you do not wish to go through the log files, you can directly check the content of this file to get the Linux kernel version

Output from RHEL/CentOS/Fedora

~]# cat /proc/version
Linux version 4.18.0-193.14.2.el8_2.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 8.3.1 20191121 (Red Hat 8.3.1-5) (GCC)) #1 SMP Sun Jul 26 03:54:29 UTC 2020

 

Output from SuSE/OpenSuSE

# cat /proc/version
Linux version 3.0.101-108.81-default (geeko@buildhost) (gcc version 4.3.4 [gcc-4_3-branch revision 152973] (SUSE Linux) ) #1 SMP Fri Nov 2 18:02:20 UTC 2018 (2208a0f)

 

Output from Ubuntu/Debian

~# cat /proc/version
Linux version 5.0.0-23-generic (buildd@lgw01-amd64-030) (gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)) #24~18.04.1-Ubuntu SMP Mon Jul 29 16:12:28 UTC 2019

 

Conclusion

In this tutorial I shared multiple commands and methods to check Linux kernel version across multiple distributions such as Ubuntu, Red Hat, CentOS, Fedora, SuSE etc. Some of the commands may not work on all the distributions which I have already highlighted wherever applicable.

Lastly I hope the steps from the article to configure NIC teaming on Linux was helpful. So, let me know your suggestions and feedback using the comment section.

Deepak Prasad

Deepak Prasad

He is the founder of GoLinuxCloud and brings over a decade of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive experience, he excels in various domains, from development to DevOps, Networking, and Security, ensuring robust and efficient solutions for diverse projects. You can connect with him on his LinkedIn profile.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can send mail to admin@golinuxcloud.com

Thank You for your support!!

Leave a Comment