I am reading through Salzman's Linux Kernel Module Programming Guide, and I was wondering about where the file linux/kernel.h is located. I couldn't find it with find. Or rather the files I found did not have any printk priority macros in them.


3 Answers 3


The linux/kernel.h header which gets used for module builds is the header which is part of the kernel source. When modules are built in the kernel source tree, that’s the version which is used.

For external module builds, the build process looks for the header in /lib/modules/$(uname -r)/build/include/linux/sched.h. That file is provided by kernel header packages, e.g. on Debian derivatives, the linux-headers-$(uname -r) package.

The /usr/include/linux/kernel.h is intended for user processes, not for kernel modules.

The printk priority macros now live in linux/printk.h and linux/kern_levels.h. I’m guessing you’re reading the original guide, which is based on the 2.6 kernel series; for modern kernels you should read the updated guide (currently for 5.6.7).


On my Mint 18.x system with the build-essential BUT not any full source tree installed -

user@localhost:~ $ locate kernel.h | grep \/kernel.h$

Per Jeff's comment on your question, I would assume that most times /usr/include/linux/kernel.h is what will be used,

I'm sure if you extract a kernel tree tarball it may have another copy in its directory structure as well. A quick check shows them all as being different sizes... or empty files.

  • locate '*/kernel.h' is how you can get locate to match the exact filename (also, locate supports regexes as well). (I'm assuming mlocate given it's Linux Mint)
    – muru
    Mar 29, 2018 at 1:05

the answer to this might significantly depend on the linux distribution... SUSE/SLES vs RHEL/Centos/Fedora vs debian vs mint and so on,

and could it also differ based on RPM flavors of linux distros vs debian ?

in any case my experience is mostly with SLES version 11.4, and for that I can vouch for


where for me   /usr/src/linux -> /usr/src/linux-3.0.101-108.21

uname -r    for me returns 3.0.101-108.21-default

as I update the kernel to newer versions, the soft link changes accordingly along with kernel.h. I think it is safe to say if you are looking for the kernel module version of kernel.h it will be under some folder related to uname -r and be part of the kernel source package for your linux distribution.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .