0

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?

Stefan Zobel
  • 3,182
  • 7
  • 28
  • 38
JenyaKh
  • 2,040
  • 17
  • 25
  • 1
    They start with a base version from kernel.org, but they often make tweaks. Typically you can download a source package for your particular distribution to get the version of the source from which your running kernel was built, including whatever patches the distribution maintainers applied. For example, `apt-get install linux-source` works on many Debian-based distributions. – eddiem Dec 01 '16 at 16:48
  • @JenyaKh it is telling you the right version, for example you get 3.2.0-4-686 Ie https://packages.debian.org/wheezy/linux-image-3.2.0-4-amd64 – Prabhakar Lad Dec 01 '16 at 16:54
  • @eddiem, so I only can look through their source code to try to find what version of Linux kernel they used? That's somehow strange. I mean why nobody using a distribution is interested in what kernel sources do they use. – JenyaKh Dec 02 '16 at 02:43
  • 1
    You know, this is really getting hard. One can not ask a question here in a way not to be minused. My question is normal. I don't see anything wrong about it. – JenyaKh Dec 02 '16 at 02:48

4 Answers4

1

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
  • Tank you for answer. But to be honest, it has not helped me yet. Do I understand right that the version of linux sources is 3.16.36 in your case? In general, that's ok, as I've found such a version of kernel here https://www.kernel.org/pub/linux/kernel/v3.0. But on my Gentoo the "uname -a" commands just produces #1 "SMP Mon Oct 24 ... 2016" -- no version. And what does "#1 SMP" means I also don't know. – JenyaKh Dec 02 '16 at 02:49
  • Yes, it means they started from a base of 3.16.36. But they applied custom patches as well, so it's not identical to the version you would download from kernel.org, which is what I mentioned above. It really depends on why you're asking the question as to whether the additional patches matter or not. – eddiem Dec 02 '16 at 12:56
  • 1
    `SMP` simply means the kernel was built with multi-processor support. `#1` indicates your kernel is the result of the first build from the kernel source on the machine where it was built. If they had tweaked some configuration and rebuilt, for example, it would show `#2`. – eddiem Dec 02 '16 at 12:59
  • What does `uname -r` show on your Gentoo example where `uname -a` supposedly shows no kernel version? – eddiem Dec 02 '16 at 12:59
  • Thank you for explanation, @eddiem, about SMP and the numbers. In my case uname -r shows "4.4.26-gentoo". However, what is "Linux Phobos 3.16.0-4-amd64" then? There is a https://packages.debian.org/jessie/linux-image-3.16.0-4-amd64 package. Maybe, your kernel sources version is 3.16.0 (not 3.16.36)? But there is no such a kernel version on linux archive site https://www.kernel.org/pub/linux/kernel/v3.0/ so, probably, I'm wrong. I'm also sorry about the long delay with my answer to your comments: I just have not been signaled them appeared. – JenyaKh Dec 03 '16 at 09:46
  • @eddiem, I've found that linux-image-3.16.0-4-amd64, linux-image-3.2.0-4-686-pae and so on should be deciphered as "linux-image-version-abiname[-featureset]-flavour": https://kernel-handbook.alioth.debian.org/ch-packaging.html – JenyaKh Dec 03 '16 at 10:05
1

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/

omilun
  • 96
  • 5
0

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

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.