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

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.

77576 次浏览

You can find the version by running

make kernelversion

In the source tree

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.

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.

In the kernel source tree, check the root directory Makefile to get the kernel version as below.


Example as below:


$ head Makefile
# SPDX-License-Identifier: GPL-2.0
VERSION = 5
PATCHLEVEL = 18
SUBLEVEL = 0
EXTRAVERSION = -rc3
NAME = Superb Owl
# *DOCUMENTATION*
# To see a list of typical targets execute "make help"
# More info can be located in ./README


From the above we get the source code version is 5.18.0-rc3

In the Linux source tree's root file, check the Makefile content. In its beginning part:

# SPDX-License-Identifier: GPL-2.0
VERSION = 4
PATCHLEVEL = 14
SUBLEVEL = 67

Then you linux source tree's version is: 4.14.67