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 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 for 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.
Some Linux kernel versions are named or tagged as mainline, stable, longterm 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 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 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.
- is the minor version.
- 29 is the path or update level which is generally added by the distribution creators.
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 the extra parameters.
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 with 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
Check/Display Linux Kernel Version from /proc/version File
Linux is a file-based operating system where information, monitoring, and configuration 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 contents of the /proc/version file which will provide detailed Kernel version information.
$ cat /proc/version
The output is like below where the 184.108.40.206 is the kernel version.
Linux version 5.8.0-29-generic ([email protected]) (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 message buffer of 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 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 for 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: 220.127.116.11.34” line provides version information for the Linux kernel.
Package: linux-generic Version: 18.104.22.168.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 (= 22.214.171.124.34), linux-headers-generic (= 126.96.36.199.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, 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