3 Ways to Check Linux Kernel Version in Command Line
Last updated June 11, 2020 By Abhishek Prakash 20 Comments
Brief: Wondering which Linux kernel version your system uses? Here are several ways to check your kernel version in the Linux terminal.
You may find yourself in a situation where you need to know the exact Linux kernel version being used on your system. Thanks to the powerful Linux command line, you can easily find that out.
Quick way to check Linux kernel version
You can use the following command to get the Linux kernel version:
uname -r
There are other ways to get even more detailed information about kernel. Read the rest of the article to learn it in detail.
In this article, I’ll show you various methods for finding out your kernel version and tell you what those numbers actually mean. If you prefer videos, here’s a quick one. Don’t forget to subscribe to our YouTube channel for more Linux tips.
How to find Linux kernel version
I am using Ubuntu while writing this article. But these commands are generic and can be used on Fedora, Debian, CentOS, SUSE Linux or any other Linux distribution.
1. Find Linux kernel using uname command
uname is the Linux command for getting system information. You can also use it to find out whether you’re using a 32-bit or 64-bit system.
Open a terminal and type in the following command:
The output will be something similar to this:
This means that you’re running Linux kernel 4.4.0-97, or in more generic terms, you are running Linux kernel version 4.4.
But what do the other digits mean here? Let me explain:
- 4 – Kernel version
- 4 – Major revision
- 0 – Minor revision
- 97 – Bug fix
- generic – Distribution-specific string. For Ubuntu, it means I’m using the desktop version. For Ubuntu server edition, it would be ‘server’.
You can also use the uname command with the option -a. This will provide more system information if you need it.
The output of the command should like this:
Let me explain the output and what it means:
- Linux – Kernel name. If you run the same command on BSD or macOS, the result will be different.
- itsfoss – Hostname.
- 4.4.0-97-generic – Kernel release (as we saw above).
- #120-Ubuntu SMP Tue Sep 19 17:28:18 UTC 2017 – This means that Ubuntu has compiled 4.4.0-97-generic 120 times. A timestamp for the last compilation is also there.
- x86_64 – Machine architecture.
- x86_64 – Processor architecture.
- x86_64 – Operating system architecture (you can run a 32-bit OS on a 64-bit processor).
- GNU/Linux – Operating system (and no, it won’t show the distribution name).
But I’ll save you from information overload. Let’s see some other commands to find your Linux kernel version.
2. Find Linux kernel using /proc/version file
In Linux, you can also find the kernel information in the file /proc/version. Just look at the contents of this file:
You’ll see an output similar to what you saw with uname.
You can see the kernel version 4.4.0-97-generic here.
3. Find Linux kernel version using dmesg commad
dmesg is a powerful command used for writing kernel messages. It’s also very useful for getting system information.
Since dmesg provides an awful lot of information, you should normally use a command like less to read it. But since we’re here just to check the Linux kernel version, grepping on ‘Linux’ should give the desired output.
The output will have a few lines but you should be able to identify the Linux kernel version there easily.
How do you check your Linux kernel version and other information?
Of the three ways discussed here, I use uname all the time. It’s the most convenient.
What about you? Which command do you prefer for getting Linux kernel information?
Like what you read? Please share it with others.
6 ways to check Linux kernel version
Published: February 7, 2017 | Modified: June 15, 2020 | 4,083 views
Learn how to check the Linux kernel version using the command line. Helpful commands to check your kernel versions, releases, codenames, etc.
This post aims at checking your Linux kernel version using commands. We will be discussing different ways to fetch this data from your system. Below is a list of commands which can be used to get Linux kernel version details.
You can use below 7 ways to gather info about your distribution like kernel version in CentOS, RHEL, SUSE, OEL, Ubuntu, Debian Linux. All the below outputs are from my test machine running CentOS 7.
1. By reading version process file.
This gives you running kernel version.
3.10.0-693.5.2.el7.x86_64 is your current kernel distribution version.
2. By reading Distro release file in /etc
Almost all distributions of Linux come with a release file in /etc which contains the kernel version, release details in it. Its a text file hence cat can be used to read its content.
OR simple use wildcard so that you can list the release file of any distro. All distro keeps diff filenames so using wildcard will be wise. In some distro, you will see /etc/os-release or /etc/system-release files as well. All these files will be covered when using wild cards.
3. By listing release package
This command works for RPM-based systems like RHEL, SUSE, OEL, CentOS, etc. Search and grep for release which will show you release package. This package name convention includes release number in it.
4. Using uname command
This command works on all flavors of Linux. You can use it on RHEL, SUSE, OEL, Debian, Ubuntu, etc.
This value indicates your current kernel version.
5. Using lsb_release command
lsb_release command is provided by redhat-lsb package. You need to install redhat-lsb package in order to use this command on RHEL, CentOS or Fedora systems.
6. Using hostnamectl command
In newer kernels, hostnamectl command is introduced. Using this command without any argument will show you all details about your kernel. You can use it to set your hostname as well.
Getting kernel version from linux kernel module at runtime
how can I obtain runtime information about which version of kernel is running from inside linux kernel module code (kernel mode)?
3 Answers 3
By convention, Linux kernel module loading mechanism doesn’t allow loading modules that were not compiled against the running kernel, so the «running kernel» you are referring to is most likely is already known at kernel module compilation time.
For retrieving the version string constant, older versions require you to include
The implementation of the virtual /proc/version procfs node uses utsname()->release .
If you want to condition the code based on kernel version in compile time, you can use a preprocessor block such as:
It allows you to compare against major/minor versions.
How to Check the Kernel Version in Linux
Updated Oct 28, 2019
The kernel is the core component of an operating system. It manages the system’s resources, and it is a bridge between your computer’s hardware and software.
There are various reasons why you might need to know the version of the kernel that is running on your GNU/Linux operating system. Perhaps you’re debugging a hardware related issue or learned about a new security vulnerability affecting older kernel versions and you want to find out whether your kernel is vulnerable or not. Whatever the reason, it’s quite easy to determine the Linux kernel version from the command line.
In this tutorial, we’ll show you several different ways to find out what version of Linux kernel is running on your system.
Using the uname Command #
The uname command displays several system information including, the Linux kernel architecture, name version, and release.
To find out what version of the Linux kernel is running on your system, type the following command:
The output above shows that the Linux kernel is 64-bit and its version is 4.15.0-54 , where:
- 4 — Kernel Version.
- 15 — Major Revision.
- 0 — Minor Revision.
- 54 — Patch number.
- generic — Distribution specific information.
Using hostnamectl command #
The hostnamectl utility is part of systemd, and it is used to query and change the system hostname. It also displays the Linux distribution and kernel version:
You can use the grep command to filter out the Linux kernel version:
Using /proc/version File #
The /proc directory contains virtual files with information about the system memory , CPU cores , mounted filesystems , and more. Information about the running kernel is stored in the /proc/version virtual file.
Use cat or less to display the contents of the file:
The output will look something like this:
Conclusion #
We have shown you how to find the version of the Linux kernel running on your system from the command line. The commands should work on all popular Linux distributions including, Debian, Red Hat, Ubuntu, Arch Linux, Fedora, CentOS, Kali Linux, OpenSUSE, Linux Mint, and more.
Feel free to leave a comment if you have any questions.