How To Check/Display Linux Kernel Version?

Linux operating system and distributions are based on the Linux kernel which is a low-level operating system layer that mainly manages all system resources and provides services to the user-level tools. Linux kernel is an open-source project and is updated regularly. Every time the Linux kernel version change. In this tutorial, we will learn how to check the Linux kernel version from the command line with different commands and GUI. In this guide, we will use common Linux commands and tools which are provided by the popular Linux distributions like Ubuntu, Debian, Mint, Kali, CentOS, RHEL, Fedora, SUSE, etc. So this tutorial can be applied to all major Linux distributions without a problem.

Linux Kernel Releases and Versions

As an open-source project, Linux kernel source code is released openly via the kernel.org website. For every version, a new source code is released. We can see that the current release is versioned as 5.9.11 and released on 24-11-2020.

https://kernel.org

Linux Kernel Releases and Versions

Some Linux kernel versions are named or tagged as mainline, stable, long-term, etc.

  • The mainline kernel version is the latest version which is currently developed actively.
  • The stable kernel version is the latest useable and stable kernel version.
  • The longterm kernel version is used by distributions to use for the longterm with long term support.

Check/Display Linux Kernel Version with uname Command

The uname command is the easiest and most popular way to list the current Linux kernel version. It also provides information about the current Linux operating system or distributions. The -r parameter can be provided to the uname command in order to display only the kernel version without any other information.

$ uname -r

The output will be like below which is the only kernel version major and minor numbers.

5.8.0-29-generic
  • 5 is the main kernel version. We can see that our kernel is the latest with the main kernel version
  • 8 is the major release version. We can see that our kernel is very near to the latest kernel manor release version.
  • 0 is the minor kernel version.
  • 29 is the path or update level which is generally added by the distribution creators.

If you are working with the FreeBSD you can use the -a option with the uname command.

uname -a

Check/Display Linux Kernel Version with hostnamectl Command

The hostnamectl is a new command which provides very useful information about the current operating system, distribution, and kernel. The kernel version will be listed in the like Kernel: like below. There is no need for extra parameters.

$ hostnamectl

The output of the hostnamectl is like below where the “Kernel: Linux 5.8.0-29-generic” line provides kernel version information which is the same as the “uname -r” command.

Static hostname: ubuntu
Icon name: computer-vm
Chassis: vm
Machine ID: 295c2cf105a140e5ab505a9e74ff560e
Boot ID: 9a37d5dd34e1444d9c6b76bd983c778f
Virtualization: vmware
Operating System: Ubuntu 20.10
Kernel: Linux 5.8.0-29-generic
Architecture: x86-64

From the output, we see that the hostnamectl command provides kernel version, major revision, minor revision, and patch number.

Check/Display Linux Kernel Version from /proc/version File

Linux is a file-based operating system where information, monitoring, and configuration are generally done via special files. The Linux kernel version is also provided via the /proc/version file. We will use the cat command in order to print the contents of the /proc/version file which will provide detailed Kernel version information.

$ cat /proc/version

The output is like below where the 5.8.0.29 is the kernel version.

Linux version 5.8.0-29-generic (buildd@lgw01-amd64-055) (gcc (Ubuntu 10.2.0-13ubuntu1) 10.2.0, GNU ld (GNU Binutils for Ubuntu) 2.35.1) #31-Ubuntu SMP Fri Nov 6 12:37:59 UTC 2020

Check/Display Linux Kernel Version with dmesg Command

The dmesg command is used to print system logs and message buffer of the Linux kernel in the command-line interface. While printing the message buffer of the Linux kernel also the kernel information is provided. We will use the grep tool in order to match the line which contains the term “Kernel” where also the version information is provided.

$ sudo dmesg | grep Linux
Check/Display Linux Kernel Version with dmesg Command

Check/Display Linux Kernel Version with apt and apt-get Command

The Linux kernel is provided via packages for different Linux distributions. Popular distributions like Ubuntu, Debian, Mint, Kali, etc. use the apt or apt-get commands to manage packages. These apt and apt-get commands can be used to print Linux kernel package information with the “apt show” or “apt-get show” command. The package name for the Linux kernel is “linux-generic“.

$ apt show linux-generic

The output is like below where the “Version: 5.8.0.29.34” line provides version information for the Linux kernel.

Package: linux-generic
Version: 5.8.0.29.34
Priority: optional
Section: kernel
Source: linux-meta
Origin: Ubuntu
Maintainer: Ubuntu Kernel Team [email protected]
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 18,4 kB
Provides: kernel-testing--linux--full--generic, kernel-testing--linux--full--preferred
Depends: linux-image-generic (= 5.8.0.29.34), linux-headers-generic (= 5.8.0.29.34)
Download-Size: 1.904 B
APT-Sources: http://tr.archive.ubuntu.com/ubuntu groovy-updates/main amd64 Packages
Description: Complete Generic Linux kernel and headers
This package will always depend on the latest complete generic Linux kernel

Alternatively, the “apt-get show linux-generic” command can be used which will produce the same output.

$ apt-get show linux-generic

Check/Display Linux Kernel Version with yum or dnf Command

The yum and dnf commands are used to install packages in RPM-based distributions like CentOS, RHEL, and Fedora. Linux kernel is provided as a package too and version information is provided for this kernel package by using the dnf or yum commands.

$ dnf show kernel

or alternatively with the yum package manager.

$ yum show kernel

/etc/issue File

The /etc/issue is another file that only stores the current distribution or Linux version. This file also exists in older or ancient Linux distributions. The cat command is used to print the Linux version via the /etc/issue file. For example, if you have Ubuntu 16.04 or like that this will work without a problem.

cat /etc/issue

Leave a Comment