3 ways to check kernel version in Linux

Table of Contents

If you’re a Linux user, it’s important to know your kernel version. The kernel is the core of the operating system, and it’s responsible for managing hardware and software resources. In this blog post, we will discuss three different ways to check your kernel version in Linux. We will also provide instructions on how to upgrade your kernel if necessary. Let’s get started!

The following commands can be used to check the kernel version in Linux.

  • uname -r
  • cat /proc/version
  • hostnamectl | grep -i kernel


Procedures to check kernel version in Linux

  • Open the terminal.
  • Type uname -r and press Enter. You will see the kernel version from the command output
  • If you want to see more information about your kernel, type uname -a and press Enter. This will show you the kernel version, as well as the date it was released and the name of the person who compiled it.


Understanding kernel version in Linux

The kernel version is important for a variety of reasons. It tells you which features are supported by your operating system, and it also provides information about the hardware compatibility.

If you need to troubleshoot a problem, the kernel version can be helpful in identifying the source of the issue. The Linux kernel is a critical part of your system, and it’s important to keep it up-to-date.

For example:Linux 4.15.0-54-generic x86_64

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.


check kernel version with uname command in Linux

The best way to check the kernel version in Linux is to use the uname command. This command will print out information about your system, including the kernel version. Open a terminal and type “uname -r”. This will print out the kernel version number.

example: uname -r

check kernel version with /proc/version file in Linux

Another way to check your kernel version is to look in the /proc/version file. This file contains information about your kernel and other system information. To view this file, simply type “cat /proc/version” in a terminal.

example: $ cat /proc/version
Linux version 4.18.0-305.el8.x86_64 ( (gcc version 8.4.1 20200928 (Red Hat 8.4.1-1) (GCC)) #1 SMP Thu Apr 29 08:54:30 EDT 2021

check kernel version with hostnamectl command in Linux

The third way to check your kernel version is to use the hostnamectl command. This command will print out information about your distribution, including the kernel version. To use the hostnamectl command, simply type “hostnamectl” in a terminal.

example: hostnamectl | grep -i kernel
Kernel: Linux 4.18.0-305.el8.x86_64

how to upgrade kernel in Linux

Now that you know how to check your kernel version, let’s discuss how to upgrade it. Upgrading your kernel is important for security and stability purposes. It’s recommended that you upgrade your kernel to the latest version available.

To upgrade your kernel, you will first need to download the kernel source code. The kernel source code is available from the Linux Kernel Archives (link below). Once you have downloaded the kernel source code, you will need to extract it. To extract the kernel source code, simply type “tar xvf [kernel source code file]” in a terminal.

Next, you will need to configure the kernel. The kernel configuration is typically located in the “.config” file in the kernel source code directory. To open and edit this file, you can use a text editor such as nano or vim. Once you have edited the kernel configuration file, you will need to compile the kernel. To compile the kernel, simply type “make” in a terminal.

Once the kernel has been compiled, you will need to install it. To install the kernel, you will need to use the “make install” command. This will install the new kernel and its modules. Once the installation is complete, you will need to reboot your system for the changes to take effect.

That’s it! You have now successfully upgraded your kernel. We hope this blog post has been helpful. If you have any questions or comments, please feel free to leave them below. Thank you for reading!

David Cao
David Cao

Hey there! I am David, a Cloud & DevOps Enthusiast and 18 years of experience as a Linux engineer. I work with AWS, Git & GitHub, Linux, Python, Ansible, and Bash. I am a technical blogger and a Software Engineer, enjoy sharing my learning and contributing to open-source.