Where do I find the version of a Linux kernel source tree?

Linux

Linux Problem Overview


I have downloaded from a hardware vendor just a tarball of their Linux source tree (no Git repository metadata), is there a way to find out the version number of the kernel?

Is the version number usually stored in a file somewhere in the source tree?

I'd like to be able to do this without compiling and running the kernel.

Linux Solutions


Solution 1 - Linux

You can find the version by running

make kernelversion

In the source tree

Solution 2 - Linux

Check the top-level Makefile, an example of which is here. At the top of that, you should see something like:

VERSION = 3
PATCHLEVEL = 1
SUBLEVEL = 0
EXTRAVERSION = -pax
NAME = Custom Pax Version

The (admittedly minor) advantage of this method is that you only need the ability to view the files themselves rather than having to run a build process.

Solution 3 - Linux

Yet another solution: in the older times include/linux/version.h, currently include/generated/uapi/linux/version.h, but only after at least a partially successful compilation.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMaksView Question on Stackoverflow
Solution 1 - LinuxAdrian CornishView Answer on Stackoverflow
Solution 2 - LinuxpaxdiabloView Answer on Stackoverflow
Solution 3 - LinuxpeterhView Answer on Stackoverflow