Check Linux Kernel Version

Check Linux Kernel Version

Linux kernel is the main component of the Linux operating system. To determine which Linux kernel version is running on the system can be useful when troubleshooting issues.

This tutorial explains how to check Linux kernel version.

1. uname command

The uname command displays information about the system. The -r option prints the Linux kernel version.

uname -r

Output:

5.4.0-72-generic

2. /proc/version file

The /proc/version file contains Linux kernel information. It can be used to determine Linux kernel version.

cat /proc/version

Output:

Linux version 5.4.0-72-generic (buildd@lcy01-amd64-019) (gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)) #80-Ubuntu SMP Mon Apr 12 17:35:00 UTC 2021

Command to get only Linux kernel version:

cat /proc/version | grep -Po "Linux version \K\S+"

3. hostnamectl command

The hostnamectl command can be used to get or set the system hostname. Command also displays Linux kernel version.

hostnamectl

Output:

Static hostname: ubuntu
       Icon name: computer-vm
         Chassis: vm
      Machine ID: 089a75bffe4b4921b2f971cc7f94f47f
         Boot ID: b493731cfb4a4152ad452df5311d6b42
  Virtualization: vmware
Operating System: Ubuntu 20.04.2 LTS
          Kernel: Linux 5.4.0-72-generic
    Architecture: x86-64

Run the following command to get only Linux kernel version:

hostnamectl | grep Kernel | grep -Po "Linux \K.+"

Leave a Comment

Cancel reply

Your email address will not be published.