To check for kernel headers and install them if necessary on Debian systems, perform the following steps.
When they are properly installed, the required kernel headers are located under
/usr/src/linux-headers-$(uname -r)/include/.
Procedure
- To determine whether kernel headers are installed, run the following command:
$ sudo apt list --installed linux-headers-$(uname -r)
If the package is installed, the output will be similar to the following. An i
or i+
in the left column signifies that the package is installed.
linux-headers-<version>-generic/…
- To determine whether the kernel headers are available to install, run the following command:
$ sudo apt search linux-headers-$(uname -r)
If the package is available, the output will be similar to the following:
linux-headers-<version>-generic/…
- To install any necessary available kernel headers, run the following command:
$ sudo apt install linux-headers-$(uname -r)
- If the kernel header packages are not installed and are not available, update the kernel to a supported version and install the matching kernel headers.
Note: This action requires a reboot.
- To list the available kernel and kernel header packages and find matching versions, run the following commands:
$ sudo apt search linux-image
$ sudo apt search linux-headers
If newer packages are available, the output will be similar to the following:
linux-image-<newer-version>-<arch>
Linux <newer-version> for 64-bit PCs (signed)
…
linux-headers-<newer-version>-<arch>
Header files for Linux <newer-version>-<arch>
…
- To install a newer supported kernel and kernel header packages with matching versions, run the following commands:
% sudo apt install kernel-default=<newer-version>
% kernel-default-devel=<newer-version>
- Reboot into the new kernel.