How to Check Linux Kernel Version {5 Options} | phoenixNAP KB (2024)

Introduction

Checking the Linux kernel version is essential for ensuring compatibility with both software and hardware. The process verifies the system meets the required specifications for running particular applications.

This tutorial explains how to check the Linux kernel version using five different methods.

How to Check Linux Kernel Version {5 Options} | phoenixNAP KB (1)

Prerequisites

  • A system running Linux (this tutorial uses Ubuntu 22.04).
  • Access to the terminal.
  • sudo or root privileges.

How to Check Linux Kernel Version via CLI

There are several ways to check the Linux kernel version via the command line. The following text elaborates on these methods.

uname Command

The uname command without any options displays system information such as the kernel name, network node hostname, kernel release, kernel version, machine hardware architecture, and operating system.

Use the -r option with uname to print the Linux kernel version only:

uname -r
How to Check Linux Kernel Version {5 Options} | phoenixNAP KB (2)

In this case, the system returns 6.5.0-27-generic. Each number, separated by a dot or hyphen, is part of a kernel version:

  • 6. - The main kernel version represents the overall Linux kernel and suggests major changes and updates to the kernel's architecture, features, and functionality.
  • .5 - The major release version signifies updates and new features introduced to the kernel.
  • .0 - The minor revision level represents smaller updates, bug fixes, and improvements within the major release.
  • -27 - The level of patches and bug fixes. It indicates the level of patches, bug fixes, and updates applied to the kernel.
  • generic - The specific configuration of the kernel. In this example, generic refers to a standard kernel configuration compatible with a wide range of hardware and system configurations.

hostnamectl Command

The hostnamectl command is used to discover and change the system hostname and to manage related settings associated with the hostname and system identification. The command also represents one way to print the Linux kernel version.

To check the kernel version, enter the following:

hostnamectl
How to Check Linux Kernel Version {5 Options} | phoenixNAP KB (3)

The output shows the current kernel version.

dmesg Command

The dmesg command shows kernel-related messages retrieved from the kernel ring buffer. This buffer stores information about hardware, device driver initialization, and messages from kernel modules, which occur during the system's startup process.

Pipe the dmesg command with grep to get messages related to the kernel version by searching for the keyword Linux version in the output. Run the following:

sudo dmesg | grep "Linux version"
How to Check Linux Kernel Version {5 Options} | phoenixNAP KB (4)

The dmesg command reads the kernel buffer content, while grep searches for the text Linux version and prints the line that contains that string of characters.

dpkg Command

The dpkg command installs, removes, and manages software packages. It also helps find the Linux kernel version.

To print the kernel version, run the following:

dpkg -l | grep linux-image
How to Check Linux Kernel Version {5 Options} | phoenixNAP KB (5)

The command lists all installed Linux kernel image packages and uses grep to filter and display lines containing the text linux-image.

Lines starting with ii indicate installed packages, while rc signifies removed packages with remaining configuration files. In this case, the current installed Linux kernel version is 6.5.0-27-generic.

via /proc/version File

The /proc/version file in Linux provides information about the kernel version, compilation options, and other details related to the operating system's kernel. To display the proc/version file, enter the command:

cat /proc/version
How to Check Linux Kernel Version {5 Options} | phoenixNAP KB (6)

The cat command prints the /proc/version file content. This outputs the Linux kernel version first, along with additional data about the operating system.

Conclusion

This guide provided several ways to check the Linux kernel version with hands-on examples.

Next, learn how to build the Linux kernel step by step.

How to Check Linux Kernel Version {5 Options} | phoenixNAP KB (2024)
Top Articles
Latest Posts
Article information

Author: Foster Heidenreich CPA

Last Updated:

Views: 6545

Rating: 4.6 / 5 (76 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Foster Heidenreich CPA

Birthday: 1995-01-14

Address: 55021 Usha Garden, North Larisa, DE 19209

Phone: +6812240846623

Job: Corporate Healthcare Strategist

Hobby: Singing, Listening to music, Rafting, LARPing, Gardening, Quilting, Rappelling

Introduction: My name is Foster Heidenreich CPA, I am a delightful, quaint, glorious, quaint, faithful, enchanting, fine person who loves writing and wants to share my knowledge and understanding with you.