How to install the kernel header file on Linux
Q: I need to install the kernel header file before installing a device driver. How to install the appropriate kernel header file?
When you compile a device driver module, you need to install the kernel header file in the system. The kernel header file is also required when you compile a user space program that is directly linked to the kernel. When installing the kernel header file in these cases, you must ensure that the kernel header file exactly matches your current kernel version (for example, 3.20.-24-generic ).
If your kernel is the kernel version that comes with the release version, or you use the basic repository of the default Package Manager to upgrade (such as apt-ger, aptitude, or yum ), you can also use the Package Manager to install the kernel header file. On the other hand, if you download the kernel source code and manually compile it, you can use the make command to install the matching kernel header file.
Now let's assume that your kernel comes with the release version. Let's take a look at how to install the matching header file.
Install the kernel header file On Debian, Ubuntu, or Linux Mint
If you have not compiled the kernel manually, you can use the apt-get command to install the matched kernel header file.
First, run the dpkg-query command to check whether there are available kernel header files.
$ dpkg-query -s linux-headers-$(uname -r)
dpkg-query: package 'linux-headers-3.11.0-26-generic' is not installed and no information is available
Run the following command to install the matched kernel header file.
$ sudo apt-get install linux-headers-$(uname -r)
Verify that the header file is successfully installed.
$ dpkg-query -s linux-headers-$(uname -r)
Package: linux-headers-3.11.0-26-genericStatus: install ok installed
The default header files of Debian, Ubuntu, and Linux Mint are under/usr/src.
Install the kernel header file on Fedora, CentOS, or RHEL
If you have not compiled the kernel manually, you can use the yum command to install the matched kernel header file.
First, run the following command to check whether the system has installed the header file. If the following command does not have any output, this means that there is no header file.
$ rpm -qa | grep kernel-headers-$(uname -r)
Then run the yum command to install the header file. This command will automatically find the appropriate header file and install it.
$ sudo yum install kernel-headers
The status of the verification package.
$ rpm -qa | grep kernel-headers-$(uname -r)
kernel-headers-3.10.0-123.9.3.el7.x86_64
The default kernel header file on Fedora, CentOS, or RHEL is/usr/include/linux.
The Ubuntu 13.10 (Saucy Salamander) Kernel has been upgraded to Linux Kernel 3.10 RC5
Linux Kernel 3.4.62 LTS is now available for download
How to install Linux kernel 13.10 On Ubuntu 3.12
How to install the 3.16.7 CKT2 kernel in Ubuntu 14.10, Ubuntu 14.04, and its derivative versions
Linux Kernel: click here
Linux Kernel: click here
This article permanently updates the link address: