How to Check Kernel Version in Linux in Command Line

Want to find out which kernel version you are running?

The Linux kernel is much like the central brain of the operating system. Although it is open-source – meaning anyone can view and modify the code – the Linux kernel is built with multiple protocols to ensure stability and security.

This guide will walk you through how to check the Linux kernel version of your distribution.

how to check linux kernel version command line

Prerequisites

  • A system running Linux (Ubuntu, Debian, RHEL, CentOS, or another version)
  • A terminal window / command line (CtrlAltT, CtrlAltF2)

4 Commands to Find Linux Kernel Version

uname Command

Launch a terminal window, then enter the following:

uname –r

The system will return a numeric code, for example:

3.10.0-957.21.2.

Each number, separated by a dot or hyphen, is part of a code:

  • 3 – This is the main kernel version
  • .10 – This is the major release version
  • .0 – This is the minor revision level
  • -957 – This is the level of patches and bug fixes
uname command to check kernel version

Theuname command includes additional options that you can use to get more information about your kernel. Simply add an option after the command:

  • -a – Display all information
  • -o – Display the operating system (usually GNU/Linux)
  • -r – Display kernel release
  • -v – Display kernel version (usually includes the base OS and time the kernel was compiled)

For a full list of uname commands, enter

uname ––help
uname command for more kernel information

Note: Your kernel version will likely be different than this example. At the time of writing this article, the latest version is Linux kernel 5.0.

hostnamectl Command

The hostnamectl command is typically used to display information about the system’s network configuration. It also displays the kernel version.

To check the kernel version, enter the following:

hostnamectl

The second-to-last line should read:

Kernel: Linux 3.10.0-957.21.2.el7.x86_64
hostnamectl

Display the /proc/version File

To display the proc/version file, enter the command:

cat /proc/version

The cat command displays the contents of the /proc/version file. This will output the Linux kernel version first, along with additional data about your operating system.

display proc_version file

dmesg Command

The dmesg command is used to print the message buffer of the kernel. This is usually used to read messages from device drivers, but it can also be used to find the kernel version.

Enter the command:

dmesg | grep Linux

The | (pipe) symbol is usually on the same key as the symbol, just above the enter key.

dmesg command

The commands work as follows:

  • dmesg – read the contents of the kernel buffer
  • | – pipe the command into the next command
  • grepsearch for a particular string of characters, and display lines that contain them
  • Linux – the exact string of characters that grep should search for (capitalization matters)

The first line of output displays the Linux kernel version.

Note: When updating your kernel, it is recommended that you choose a release version that’s compatible with your version of Linux. Your package manager will typically give you kernel versions that are tested and verified.

Conclusion

This guide showed you several different ways to check the Linux kernel version. Since you’re only reading the output of a file, you shouldn’t need sudo privileges.

The Linux kernel has a modular design. Functionality is extendible with modules or drivers. Learn how to use the modprobe command to add or remove modules on Linux.

原创文章,作者:3628473679,如若转载,请注明出处:https://blog.ytso.com/223944.html

(0)
上一篇 2022年1月7日
下一篇 2022年1月7日

相关推荐

发表回复

登录后才能评论