How to Check Kernel Version in Linux in Command Line

June 25, 2019

Want to find out which kernel version you are running?

The Linux kernel is much like the central brain of the operating system. Although it is open-source – meaning anyone can view and modify the code – the Linux kernel is built with multiple protocols to ensure stability and security.

This guide will walk you through how to check the Linux kernel version of your distribution.

how to check linux kernel version command line

Prerequisites

  • A system running Linux (Ubuntu, Debian, RHEL, CentOS, or another version)
  • A terminal window / command line (CtrlAltT, CtrlAltF2)

4 Commands to Find Linux Kernel Version

uname Command

Launch a terminal window, then enter the following:

uname –r

The system will return a numeric code, for example:

3.10.0-957.21.2.

Each number, separated by a dot or hyphen, is part of a code:

  • 3 – This is the main kernel version
  • .10 – This is the major release version
  • .0 – This is the minor revision level
  • -957 – This is the level of patches and bug fixes
uname command to check kernel version

Theuname command includes additional options that you can use to get more information about your kernel. Simply add an option after the command:

  • -a – Display all information
  • -o – Display the operating system (usually GNU/Linux)
  • -r – Display kernel release
  • -v – Display kernel version (usually includes the base OS and time the kernel was compiled)

For a full list of uname commands, enter

uname ––help
uname command for more kernel information

Note: Your kernel version will likely be different than this example. At the time of writing this article, the latest version is Linux kernel 5.0.

hostnamectl Command

The hostnamectl command is typically used to display information about the system’s network configuration. It also displays the kernel version.

To check the kernel version, enter the following:

hostnamectl

The second-to-last line should read:

Kernel: Linux 3.10.0-957.21.2.el7.x86_64
hostnamectl

Display the /proc/version File

To display the proc/version file, enter the command:

cat /proc/version

The cat command displays the contents of the /proc/version file. This will output the Linux kernel version first, along with additional data about your operating system.

display proc_version file

dmesg Command

The dmesg command is used to print the message buffer of the kernel. This is usually used to read messages from device drivers, but it can also be used to find the kernel version.

Enter the command:

dmesg | grep Linux

The | (pipe) symbol is usually on the same key as the symbol, just above the enter key.

dmesg command

The commands work as follows:

  • dmesg – read the contents of the kernel buffer
  • | – pipe the command into the next command
  • grepsearch for a particular string of characters, and display lines that contain them
  • Linux – the exact string of characters that grep should search for (capitalization matters)

The first line of output displays the Linux kernel version.

Note: When updating your kernel, it is recommended that you choose a release version that’s compatible with your version of Linux. Your package manager will typically give you kernel versions that are tested and verified.

Conclusion

This guide showed you several different ways to check the Linux kernel version. Since you’re only reading the output of a file, you shouldn’t need sudo privileges.

The Linux kernel has a modular design. Functionality is extendible with modules or drivers. Learn how to use the modprobe command to add or remove modules on Linux.

Was this article helpful?
YesNo
Sofija Simic
Sofija Simic is an aspiring Technical Writer at phoenixNAP. Alongside her educational background in teaching and writing, she has had a lifelong passion for information technology. She is committed to unscrambling confusing IT concepts and streamlining intricate software installations.
Next you should read
How to Check Memory Usage in Linux, 5 Simple Commands
June 18, 2019

In this tutorial, learn the five most commonly used commands to check memory usage in Linux. We also provide...
Read more
How to Check the OpenSSL Version Number
June 13, 2019

OpenSSL is an open-source cryptographic library and SSL toolkit. The applications contained in the library...
Read more
Linux Kernel 5.0 Released, New Features & Improvements!
April 3, 2019

The long-awaited Linux Kernel 5.0 upgrade is finally out, and it is time to take a look at all the new...
Read more
How to Update Linux Kernel In Ubuntu
October 22, 2018

The Linux kernel is like the central core of the operating system. It works as sort of a mediator, providing...
Read more
  • © 2021 Copyright phoenixNAP | Global IT Services. All Rights Reserved.