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

Clinton Roy clinton.roy at gmail.com
Thu Nov 24 12:35:46 AWST 2016


On Thu, 24 Nov 2016 at 13:36 Bill Kenworthy <billk at iinet.net.au> wrote:

> What's the best way to get kernel version from a binary?
>
>
Is this a standard(ish) linux kernel? I would use the magic library that
sits behind file(1)

in python:

import magic
description = magic.detect_from_filename('/boot/vmlinux').name

Then you'll have a string like:

Linux kernel x86 boot executable bzImage, version 4.9.0-rc5-amd64 (
debian-kernel at lists.debian.org) #1 SMP Debian 4.9~rc5-1~exp1 (2016-11-14),
RO-rootFS, swap_dev 0x3, Normal VGA

to deal with, but that'll be fairly stable and pretty easy to parse.

hth,
-- 
-- Clinton Roy, Software Engineer with Bloomberg L.P.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.plug.org.au/pipermail/plug/attachments/20161124/d5588d3d/attachment.html>


More information about the plug mailing list