Possible Duplicate:
What does a kernel source tree contain? Is this related to Linux kernel headers?

I know that if I want to compile my own Linux kernel I need the Linux kernel headers, but what exactly are they good for?

I found out that under /usr/src/ there seem to be dozens of C header files. But what is their purpose, aren't they included in the kernel sources directly?


3 Answers 3


The header files define an interface: they specify how the functions in the source file are defined.

They are used so that a compiler can check if the usage of a function is correct as the function signature (return value and parameters) is present in the header file. For this task the actual implementation of the function is not necessary.

You could do the same with the complete kernel sources but you will install a lot of unnecessary files.

Example: if I want to use the function

int foo(double param);

in a program I do not need to know how the implementation of foo is, I just need to know that it accepts a single param (double) and returns an integer.

  • if you are not compile something, can you purge these really big packages?
    – Chameleon
    Apr 5, 2020 at 12:10
  • 1
    @Chameleon Yes you con
    – Matteo
    Apr 5, 2020 at 12:11

As stated, header files define interfaces to functions as well as structures used by programs.

In the case of the kernel header files, these functions and structures are within the kernel itself.

If you are building a complete kernel, then, obviously, you need the complete source files, not just the headers. However, if you are compiling a device driver or other loadable module which links into the kernel then you only need the header files, so can save space by not installing the full sources.

The separation of packages so that you can install just the header files is partly historical as the difference in disk usage used to be a significant consideration when disks were smaller. These days, having the entire source on disk (unnecessarily) would not be a major disk space consideration.

  • To sum up: header files are all downloaded to the local system, but the kernel function files only when required.
    – Timo
    Sep 1, 2020 at 8:24

The term header files originates from the C programming language used in writing the Linux kernel.

To explain it from a very high level...

In C, you need to have a forward declaration of a function before using it. In other words, a description of the function, its parameters, and what kind of data it returns. It's common practice to put all of the forward declarations into a single file called a header. Source code files for other programs can then include this header and have access to all of the functions in the resulting program executable once it has been compiled.

The Linux header files are all of the .h files that contain the functions that the Linux kernel provides that can be called from other programs.

Not the answer you're looking for? Browse other questions tagged or ask your own question.