Knowing the current version of the kernel on a Linux system is very important for several reasons - one being when adding modules to the kernel. Well, it's no big deal in retrieving this information. Here are four ways to glean this information:
1) $ uname -r
- This command is going to spit out exactly what you need. Just add water and stir (i.e. just type in the command, and press ENTER).
2) $ cat /proc/version
- This command is going to provide you with a little bit more than the Linux kernel version, but it certainly won't be hard to identify kernel version information
3) $ hostnamectl
- You probably weren't expecting to see this one, because you've used it primarily when managing hostname information for a Linux system. Well, in addition to that duty, it also provides the version of the Linux kernel. In the 16 lines of information that it provides, just look for the line that begins with the word "Kernel".
Note: The hostnamectl command is a component of systemd, which means that you'll have no trouble in using it on a RHEL system. However, as you've already assessed, this command is not available on a Linux system that is not using systemd. Just thought I'd through that in for those of you who "might" spend time with other distros.
4) $ dmesg | grep "Linux version"
- Because the dmesg command can spit out a lot of info, it might be a good idea to filter for "Linux version". This is not a requirement - just an efficiency suggestion.
Take your pick - the choice yours!!!
You made it..!
Thanks for sharing..!
Thanks for viewing!!!!
Nice inclusion! I appreciate that you pointed out /proc/version provides more than just the kernel version—it's also useful for seeing the build time and compiler details.
/proc/version offers a lot of juice for the squeeze!!!
@Trevor apart from what you mentioned here is one more option :
sysctl -n kernel.osrelease
which reads from /proc/sys/kernel/osrelease
Chetan, you've once again demonstrated why you're the Community Manager! It's a guarantee that you will elevate the discussion!!
Thanks Chetan for that very insightful addition!!!
Let's not forget these:
rpm -qi kernel | grep Version
dnf info kernel | grep Version
Wut up TB! Only a deep thinker like yourself could think about going that route!!!
That approach is not part of my repertoire. Well, it is now!!!
Thanks TB for expanding my knowledgebase!!!
And let's not forget Ansible:
`ansible localhost -m setup | grep kernel`
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.