cancel
Showing results for 
Search instead for 
Did you mean: 
Trevor
Starfighter Starfighter
Starfighter
  • 536 Views

Kernel Version

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!!!

Trevor "Red Hat Evangelist" Chandler
Labels (3)
10 Replies
Blue_bird
Flight Engineer
Flight Engineer
  • 477 Views

You made it..!

Thanks for sharing..!

Trevor
Starfighter Starfighter
Starfighter
  • 443 Views

Thanks for viewing!!!!

Trevor "Red Hat Evangelist" Chandler
shashi01
Moderator
Moderator
  • 447 Views

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.

Trevor
Starfighter Starfighter
Starfighter
  • 442 Views

/proc/version offers a lot of juice for the squeeze!!!

Trevor "Red Hat Evangelist" Chandler
Chetan_Tiwary_
Community Manager
Community Manager
  • 354 Views

@Trevor apart from what you mentioned here is one more option :

sysctl -n kernel.osrelease

which reads from /proc/sys/kernel/osrelease

Chetan_Tiwary__0-1746627899148.png

 

Trevor
Starfighter Starfighter
Starfighter
  • 340 Views

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!!!

 

 

 

Trevor "Red Hat Evangelist" Chandler
Tracy_Baker
Starfighter Starfighter
Starfighter
  • 297 Views

Let's not forget these:

rpm -qi kernel | grep Version

dnf info kernel | grep Version

 

Program Lead at Arizona's first Red Hat Academy, est. 2005
Estrella Mountain Community College
Trevor
Starfighter Starfighter
Starfighter
  • 290 Views

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!!!

 

 

Trevor "Red Hat Evangelist" Chandler
DavidOBrien
Starfighter Starfighter
Starfighter
  • 217 Views

And let's not forget Ansible:

`ansible localhost -m setup | grep kernel`

Tags (1)
Join the discussion
You must log in to join this conversation.