I need to install the linux-header-* package for other kernel versions in order to compile a kernel module locally for a different system.

Say, I want to compile for Debian 10, with a kernel version of 4.19.0-13-amd64, using Ubuntu 20.10, with a kernel version of 5.8.0-43-generic.

In that case, is it possible to install the neccessary linux-headers-4.19.0-13-amd64 package from the Ubuntu 20.10 machine?

In particular, apt-cache search linux-headers-.* only show 5.8.0-* versions on Ubuntu 20.10.

If not possible to download the necessary kernel headers using apt-get, where can these be obtained? I don't want the complete Linux source, just the headers required for compiling the kernel module.

  • Don’t, use pbuilder instead — that way you’ll get the same headers and the same compiler etc. Commented Mar 5, 2021 at 14:18
  • 1
    @StephenKitt - Thank you. Do you also know whether it's possible to download a .tar archive from e.g. kernel.org containing just the kernel headers (linux-headers-*), or is only the complete source available? In case only the complete source is available, ca nthe relevant kernel headers easily be extracted to form the linux-headers-*-equivalent?
    – Shuzheng
    Commented Mar 5, 2021 at 14:28

1 Answer 1


You can't install the debian linux-headers on Ubuntu but you can download the source:

Add only the debian sources , it doesn't harm ubuntu:

printf "%s\n" "deb-src http://deb.debian.org/debian buster main" |\
sudo tee /etc/apt/sources.list.d/debian-src.list

Add the gpg keys:

sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com  04EE7237B7D453EC 648ACFD622F3D138 DCC9EFBF77E11517
sudo apt-key update

Download the source:

apt source linux-headers-4.19.0-14-amd64

The linux-headers-4.19.0-13-amd64 is available from debian snapshot.

  • Thank you. But why do you add deb.debian.org, if you download from snapshot.debian.org?
    – Shuzheng
    Commented Mar 5, 2021 at 18:38
  • Ohh, apt is actually downloading the kernel headers from deb.debian.org, which is current?
    – Shuzheng
    Commented Mar 5, 2021 at 18:43
  • @Shuzheng Yes this should the current version 4.19.0-14, if you need an old one you can use debian snapshot.
    – GAD3R
    Commented Mar 5, 2021 at 18:45
  • Which mechanism blocks the installation of the Debian kernel headers on Ubuntu? Is apt smart enough to detect that the package is not created for the target system (Ubuntu)?
    – Shuzheng
    Commented Mar 5, 2021 at 18:45
  • 1
    No, apt can’t detect that a package wasn’t created for the target system; it follows the repository configuration. You can’t install Debian kernel headers in Ubuntu by default because the Ubuntu repositories don’t provide them. This configuration only gives access to package sources, so it is safe. Commented Mar 8, 2021 at 8:18

You must log in to answer this question.

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