How can I find out the Linux kernel version?

How to find out the Linux kernel version

The various Linux distributions are based on what is known as a Linux kernel, and each distribution comes with a version of the Linux kernel. This is a central and indispensable element in the interaction between hardware, system and applications. This means that a Linux kernel is used by Debian, Ubuntu and Kali Linux, Rocky LinuxFedora, CentOS, etc...

The Linux kernel is regularly updated, both to correct bugs and to improve vulnerabilities, but also to introduce new features. How can you tell which version of the Linux kernel a machine is running? This is what we're going to find out by means of a number of commands.

We could say that the Linux kernel manages communication between the computer's hardware and software layers. The Linux kernel is also called Linux kernel. At the time of writing, the latest version of the Linux kernel is 5.19.8. This is a minor version of Linux kernel 5.19, which is a major version. The main changes are integrated into the major releases.

1. Linux kernel version with uname

The uname command is essential under Linux. It is one of the most basic commands. The first command below provides a variety of system information:

uname -a

To obtain only the Linux kernel version, use the "-r" option:

uname -r

This command returns the kernel version and architecture. No more, no less. The image below clearly shows the difference.

Linux kernel version with uname

2. Linux kernel version with /proc/version

The system file /proc/version provides information about the machine's Linux kernel. It gives the exact version of the Linux kernel, but also information on the GCC compiler used to build this kernel, as well as the date and time of compilation.

Since this is a file, its contents can be displayed with the cat command. For example :

cat /proc/version

As in the previous example, we can see that my machine uses the Linux kernel "5.10.0-16-amd64", with the last information (amd64) corresponding to the machine architecture. Here, it's 64-bit.

3. Linux kernel version with hostnamectl

In addition to the above methods, the hostnamectl is used to manage the hostname of the Linux machine. Beyond that, this command provides information about the system: current host name, machine type, machine ID, operating system, architecture and, of course, kernel version.

To obtain this information, this command is used without the option :

hostnamectl

The output shows the line "Kernel" followed by a value corresponding to the version of the Linux kernel on this machineunder Debian in this example.

Linux kernel version with hostnamectl

If we take the example above, we can determine that the Linux kernel version is "5.10.0-16-amd64" and that the machine is running Debian 11 Bullseye.

4. Conclusion

These three commands are very useful! Personally, I like to use hostnamectl to obtain a range of information at a glance, such as kernel version, operating system version, etc., without having to use several commands. On the other hand, in a script, in Bash for example, it's easier to use "uname -r" because you only get the kernel version.

To update the Linux kernel, you need to use the package manager of the distribution you're using. Taking Debian (or Ubuntu) as an example, which uses "apt", you'll need to issue the following commands:

sudo apt-get update
sudo apt-get upgrade

If there is a kernel update, it will be installed at the same time as the packages waiting for an update.

After reading this article, you will be able to retrieve the Linux kernel version of your server or workstation which runs on a Linux distribution.

Resources :

You may also like...

Leave a Reply

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