We’ll cover the different methods to find the Linux kernel version. A kernel acts as the core of an operating system, with the task of controlling every operation that happens on the system. From handling basic input/output requests to memory management, kernel plays an important role.
In this article, we will be going through different ways to check the kernel version in Linux.
Using the uname command to find the Linux kernel version
uname deals with information related to the operating system. The kernel is the essence of an operating system and therefore falls under the knowledge of uname
command. 'uname -r'
prints the current running kernel version in Linux.
uname -r
Kernel version details:
Kernel version is composed of multiple release information.
- 5 – The main kernel version
- 3 – A major revision in the kernel. Formerly, Linux used to indicate stable releases using even number (1.2, 2.6) while odd numbers (1.5, 2.3) suggested development releases.
- 0 – A minor revision in the kernel.
The kernel version is 5.3.0
- 28 – An immediate bug fix
- generic – Distribution specific information
More details about ‘uname’ command
As we mentioned, uname
contains information related to the operating system. If no options are provided with the uname
command, it displays the name of the operating system.
To print the type of processor, -p
or --processor
is used as an option:
uname -p
We can learn more about uname
command by reading its manual page. It can be accessed in the terminal by:
man uname
Through the ‘proc’ file system
Proc contains files having information about processes and other system information like memory and kernel modules. To list the files in ‘proc’, we use the ls command:
ls /proc
To extract the information stored in ‘version’ file, we use the cat command:
cat /proc/version
It must be clear to any Linux user that proc is a virtual file system in all Linux systems. We can access it from any directory using the terminal.
Using ‘hostnamectl’ command
hostnamectl
as in “Control the system hostname”, is a Linux utility that is used to query as well as change system’s hostname linked settings.
In order to fetch kernel version using hostnamectl
, we make use of the grep command by:
hostnamectl | grep -i kernel
Note: In the command, the pipe symbol ‘|’ is used to pass the output of the first sub-command as an input to the following sub-command. The
-i
option used with thegrep
command is to search the string case-insensitively.
More details on ‘hostnamectl’ command
This command can change the current static host name by:
hostnamectl set-hostname linuxfordevices
After restarting the terminal, you can see the changes rolled in the prompt.
Utilizing ‘dmesg’ command
The term dmesg
stands for “diagnostic messages”. It basically outputs the messages from the device drivers. To make use of this command for extracting kernel version we again make use of grep
command by:
dmesg | grep -i "linux version"
Note: It is necessary to enclose linux version in inverted commas, otherwise the
grep
command will consider only linux as the target string.
For Ubuntu/Debian Linux: dpkg command
dpkg – Debian Package, is a tool for installing, removing, and managing Debian packages. It can also be used to fetch all the installed Linux kernels. This can be done by:
dpkg -l | grep -i "linux-image"
The 'ii'
at the start of the output means that the following Linux image is already installed. This command does not mention the running kernel version but instead displays all the installed ones.
Conclusion:
As we have seen, there are multiple ways to find the kernel version in Linux, but the most simple way is using uname
command. We hope that this article was up to your expectations. If we might have missed a way to find out the kernel version in Linux, then feel free to tell us below.