Prerequisites
- A system running Linux (Ubuntu, Debian, RHEL, CentOS, or another version)
- A terminal window / command line (Ctrl–Alt–T, Ctrl–Alt–F2)
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
The uname
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
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
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.
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.
The commands work as follows:
dmesg
– read the contents of the kernel buffer|
– pipe the command into the next commandgrep
– search for a particular string of characters, and display lines that contain themLinux
– 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.
Credits: Redhat, Ubuntu, Linux, Phoenixnap