check linux kernel version

How to Check Kernel Version in Linux

Kernel is one of the most important parts of Linux operating system that manages processes, resources and allows software to communicate with hardware. Sometimes you may need to check Kernel version in Linux to download proper drivers, security patches or updates for it. You may also need this information to fix hardware issues. In this article, we will look at how to check kernel version in Linux.


How to Check Kernel Version in Linux

Here are the different ways to check kernel version in Linux.


1. Using uname

uname command gives detailed information about your system such as processor, architecture and also kernel information. You can easily get kernel version with the following command.

$ uname -r
5.10.0-051000-generic

In the above output, 5 is Kernel version, 10 is Major revision, 0 is Minor revision and 051000 is Patch number.


2. Using dmesg

dmesg is a useful tool to create kernel messages. It can also be used to get kernel version number. Its output contains a lot of information, so we will pass it to grep command and search for ‘Linux’ string to get the kernel version number.

$ sudo dmesg | grep Linux
[    0.000000] Linux version 5.4.0-1054-aws (buildd@lgw01-amd64-036) (gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)) #57~18.04.1-Ubuntu SMP Thu Jul 15 03:21:36 UTC 2021 (Ubuntu 5.4.0-1054.57~18.04.1-aws 5.4.124)
[    0.995127] ACPI: Added _OSI(Linux-Dell-Video)
[    0.999196] ACPI: Added _OSI(Linux-Lenovo-NV-HDMI-Audio)
[    1.003120] ACPI: Added _OSI(Linux-HPI-Hybrid-Graphics)
[    1.403141] pps_core: LinuxPPS API ver. 1 registered
[    2.170883] Linux agpgart interface v0.103


3. Using hostnamectl

Hostnamectl is a useful tool to change system host name. It can also be used to get kernel version.

$ hostnamectl
   Static hostname: ip-172-30-0-145
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 68092f3dbbd24536a510a39661c1410f
           Boot ID: c7097a1b44b1447ba1a64687ad3b2c1d
    Virtualization: xen
  Operating System: Ubuntu 18.04.3 LTS
            Kernel: Linux 5.4.0-1054-aws
      Architecture: x86-64

The above command contains a lot of information. If you only want to extract kernel version number, use it with grep command as shown below.

$ hostnamectl | grep -i kernel
            Kernel: Linux 5.4.0-1054-aws


4. Using /proc/version file

Linux creates a temporary file /proc/version at the system boot and it is deleted when you shutdown your system. It stores kernel version number that you can easily view using cat command.

$ cat /proc/version
Linux version 5.4.0-1054-aws (buildd@lgw01-amd64-036) (gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)) #57~18.04.1-Ubuntu SMP Thu Jul 15 03:21:36 UTC 2021

That’s it. In this article, we have looked at various ways to get kernel version information. You can use any of these command as per your requirement. They will all give you the same information.

Linux Kernel consists of hardware device drivers, process management, filesystem drivers, memory management, network management, and various other things. To debug any of these kernel aspects, you may need to know the kernel version.

Also, knowing kernel version can be important sometimes to understand the various features available in it, and also be able to quickly identify its security vulnerabilities. It can also help you determine its load capacity for performance benchmark tests.

Also read:

How to Create CSR for Wildcard SSL Certificate
How to Remove Unused Kernels in Ubuntu
How to Remove old or unused Kernels in RHEL/Fedora/CentOS
How to Install Sublime Text in Linux
HAProxy Load Balancer Configuration

Leave a Reply

Your email address will not be published. Required fields are marked *