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!!!
David, that's definitely an option. However, inorder to execute that ansible command, the package that contains that command may not be installed. Now, the user has to interrogate the package that the command resides. Then, that package has to be installed. Some users may be lazy like myself, and may not want to go thourgh those extra steps
Anyway, for those users who would like to have a look at David's command, you'll need to have the ansible-core package installed!
And just to sprinkle a little extra spice on David's command, I'll replace the grep pattern with -w ansible_core: ansible localhost -m setup | grep -w ansible_core
Thanks David for your idea. That throws an extra log on the fire, and elevates everyone's knowledgebase - it did for me anyway!
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.