[plug] What's the best way to get kernel version from a binary?

Brad Campbell brad at fnarfbargle.com
Thu Nov 24 12:11:09 AWST 2016


On 24/11/16 11:35, Bill Kenworthy wrote:
> What's the best way to get kernel version from a binary?
>
> Context is that the raspberry pi stock firware doesn’t use version
> numbers in the filename and I want to know what kernel version I am
> building a custom initrd using dracut for a btrfs on root filesystem.
>
> Easy to get manually (strings|grep the file) but its clumsy and hard to
> get precision in a script and uname doesn’t work on a file :(
>
> BillK
> _______________________________________________
> PLUG discussion list: plug at plug.org.au
> http://lists.plug.org.au/mailman/listinfo/plug
> Committee e-mail: committee at plug.org.au
> PLUG Membership: http://www.plug.org.au/membership
>

This is how I've done it for years now, it works no matter what weird 
extensions get put on the version. :

brad at srv:/raid10/src/linux-stable$ strings vmlinux | grep "Linux 
version" | awk '{print $3}'
4.8.6
brad at srv:/raid10/src/linux-stable$ strings vmlinux | grep "Linux version"
Linux version 4.8.6 (brad at srv) (gcc version 4.7.2 (Debian 4.7.2-5) ) #8 
SMP Mon Nov 7 14:36:58 AWST 2016



More information about the plug mailing list