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/.

Prerequisites

Check BPF-based Sensor Requirements

Procedure

  1. 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/…

  2. 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/…

  3. To install any necessary available kernel headers, run the following command:
    $ sudo apt install linux-headers-$(uname -r)
  4. 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.
    1. 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>

    2. 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>
    3. Reboot into the new kernel.