How do I know what linux kernel version does a distribution use?

2.3k views Asked by At

When I run

uname -r

I get 3.2.0-4-686-pae on my Debian7 and 4.4.26-gentoo on my Gentoo.

But what I can't find anywhere is what Linux kernel source versions do these distributions use. If I understand right all distributions take the kernel source code from here https://www.kernel.org. So how can I find out what Linux kernel versions from the site do use 4.4.26-gentoo or 3.2.0-4-686-pae, for example?

4

There are 4 answers

6
Lord_PedantenStein On

Try man uname and find -v for the kernel version used. ;)

So it is uname -v or uname -a if you just dont care about specifics and want to see it all. :p

$ uname -v
#1 SMP Debian 3.16.36-1+deb8u2 (2016-10-19)

$ uname -a
Linux Phobos 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u2 (2016-10-19) x86_64 GNU/Linux

Check out the difference between the uname -r part and the uname -v part in uname -a (the first version number in -a)

$ uname -r
3.16.0-4-amd64
0
omilun On

you have some way to know linux kernel version :

  1. good way

    uname -r

  2. bad way to see kernel version ( you should see version of vmlinu* initrd files if they have version number of kernel )

    ls /boot | grep "vmlinu*"; ls /boot | grep "initrd*"

  3. you can try this way to know all of kernel versions on your machine :

    ls /lib/modules/

0
Dude-with-the-long-username On

uname -r is the easiest way.

though there are utilities like screenfetch or neofetch that give you more information in a clear and pretty manner.

Just run screenfetch and it'll display details. (screenfetch is usually pre-installed on most distros these days).

If it is not installed, just run sudo apt install screenfetch (on debian based distros like ubuntu) or sudo pacman -S screenfetch ( on Arch based distros.

0
Liyong Zhou On

If you are looking for original Linux kernel version that matches browse-able

https://elixir.bootlin.com/linux/vx.y.z/

or LINUX_KERNEL_CODE you check when developing kernel code, "uname" is not the right answer!

There are two methods (I use my Ubuntu 16.04 as example):

  1. dmesg

    dmesg | grep "Linux\ version"

    [ 0.000000] Linux version 4.4.0-210-generic (buildd@lgw01- amd64-009) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0- 6ubuntu1~16.04.12) ) #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 (Ubuntu 4.4.0-210.242-generic 4.4.262)

The original kernel version is 4.4.262! And 4.4.0-210-generic is Ubuntu's kernel number.

  1. Install the kernel source use command like

    sudo apt-get install linux-source

Look at the newly installed file ('uname -r' => 4.4.0-210-generic)

/lib/modules/4.4.0-210-generic/build/include/generated/uapi/linux/version.h    

#define LINUX_VERSION_CODE 263423
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))

That version code is 0x0404FF indicating 4.4.[>=255] (where FF is for when patch exceeds 255).

-------- interesting reading below--------

It is interesting to look at the file

/lib/modules/4.4.0-210-generic/build/include/generated/utsrelease.h
#define UTS_RELEASE "4.4.0-210-generic"
#define UTS_UBUNTU_RELEASE_ABI 210

Now we know where uname and /proc/version get their number.

On my Ubuntu 20.04 5.4.0-80-generic

dmesg | grep "Linux\ versin"

[    0.000000] Linux version 5.4.0-80-generic (buildd@lcy01-
amd64-030) (gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04))
#90-Ubuntu SMP Fri Jul 9 22:49:44 UTC 2021 
(Ubuntu 5.4.0-80.90-generic **5.4.124**)

and LINUX_KERNEL_CODE is

$ cat /lib/modules/5.4.0-80-generic/build/include/generated/uapi/linux/version.h 

#define LINUX_VERSION_CODE 328828

where 328828 = 0x05047C, indicating 5.4.124.