Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

linux

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.

like image 269
Maks Avatar asked Aug 28 '12 01:08

Maks


People also ask

Where is kernel version in source?

To check Linux Kernel version, try the following commands: uname -r : Find Linux kernel version. cat /proc/version : Show Linux kernel version with help of a special file. hostnamectl | grep Kernel : For systemd based Linux distro you can use hotnamectl to display hostname and running Linux kernel version.

Where is Linux kernel tree?

The kernel source is typically installed in /usr/src/linux. You should not use this source tree for development because the kernel version against which your C library is compiled is often linked to this tree.


3 Answers

You can find the version by running

make kernelversion 

In the source tree

like image 198
Adrian Cornish Avatar answered Oct 17 '22 09:10

Adrian Cornish


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.

like image 41
paxdiablo Avatar answered Oct 17 '22 07:10

paxdiablo


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.

like image 39
peterh Avatar answered Oct 17 '22 07:10

peterh