Debian / Ubuntu Linux Install Kernel Headers Package

See all Debian/Ubuntu Linux related FAQ
I need kernel headers to compile module for vmware tools or Virtualbox guest. How do I install the Linux kernel headers on Debian or Ubuntu Linux operating systems using command line options?

Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements None
Est. reading time 2 minutes
You can easily install the Linux kernel headers for currently running kernel version using the following commands at shell prompt. Header files and scripts for building modules for Linux kernel are included in linux-header-YOUR-Kernel-Version package. Open a terminal and type the command as root user to install linux-headers* package for your running kernel.

Make sure you have updated version

Type the following apt-get command or apt command:
$ sudo apt-get update
OR as root user enter:
# apt-get update

Search for kernel version (optional)

Type the following apt-cache command :
$ apt-cache search linux-headers-$(uname -r)
$ apt search linux-headers-$(uname -r)
Sample outputs:

Sorting... Done
Full Text Search... Done
linux-headers-4.9.0-3-amd64/testing,now 4.9.30-2 amd64 [installed]
  Header files for Linux 4.9.0-3-amd64

Install linux-header package under Debian or Ubuntu Linux

Type the following apt-get command:
$ sudo apt-get install linux-headers-$(uname -r)
Here is output from the latest Debian 9:

Fig.01: Installing the Linux kernel header using apt-get

Fig.01: Installing the Linux kernel header using apt-get

# apt-get install linux-headers-$(uname -r)
Sample outputs from older system:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  binutils cpp-4.3 gcc-4.3 gcc-4.3-base libc-dev-bin libc6-dev libgmp3c2 libgomp1 libmpfr4
  linux-headers-2.6.32-5-common linux-kbuild-2.6.32 linux-libc-dev manpages-dev
Suggested packages:
  binutils-doc gcc-4.3-locales gcc-4.3-multilib libmudflap0-4.3-dev gcc-4.3-doc libgcc1-dbg
  libgomp1-dbg libmudflap0-dbg glibc-doc
Recommended packages:
  gcc c-compiler
The following NEW packages will be installed:
  binutils cpp-4.3 gcc-4.3 gcc-4.3-base libc-dev-bin libc6-dev libgmp3c2 libgomp1 libmpfr4
  linux-headers-2.6.32-5-amd64 linux-headers-2.6.32-5-common linux-kbuild-2.6.32 linux-libc-dev
0 upgraded, 14 newly installed, 0 to remove and 0 not upgraded.
Need to get 20.8 MB of archives.
After this operation, 68.9 MB of additional disk space will be used.
Do you want to continue [Y/n]? y

Once installed you can compile modules for VMWare or VirtualBox or anything else you needed. Also make sure you install GNU GCC compiler collection on Debian/Ubuntu Linux:
$ sudo apt-get install build-essential

See page for more information.

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

40 comments… add one
  • Deric Jul 23, 2011 @ 0:27

    I have a Freescale i.MX53 quick start board. I need to compile a kernel module for it so I want to install the kernel headers package . The “uname -r” and “ls /lib/modules” both show

    First of all, “sudo apt-get update” has a connection error (I verfied the Internet connection is working for this board):
    W: Failed to fetch
    Unable to connect to

    Second, apt-get can not find the package linux-headers- or linux-headers- or linux-headers-

    Can somebody help me out?

    Thank you.

    • Samy Sep 15, 2011 @ 8:30

      Hi Deric,

      I am also facing the same issue now. I need to have kernel package to build kernel module. If you have found where to get it. Please share the information.


      • Janis Sep 16, 2011 @ 9:33

        probably need to ask the hardware developer for that

  • Cosmin Jan 29, 2012 @ 14:17

    Thank you very much, I spent a lot of time searching forums for a solution for this and you solved it in three lines of text.

  • Kayhan KAYIHAN Feb 4, 2012 @ 11:43

    good method, thanks.

  • Alex Feb 10, 2012 @ 6:52

    XMBC ferezes badly – as in, horribly (sound loops until I shut down my computer) on my comp when I pause it.

  • LinuxNoob Mar 12, 2012 @ 10:30

    Can anyone tell me how to do the same thing without “Internet Connectivity/Offline”?
    because my Linux machine doesn’t have internet,

  • Jun 3, 2012 @ 23:34

    Great information!!!
    Ditto for CentOS:

  • vicky Aug 21, 2013 @ 17:20

    sudo apt-get install linux-headers-$(uname -r) does’t work…!!! Anybody help

    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to locate package linux-headers-3.10.4
    E: Couldn’t find any package by regex ‘linux-headers-3.10.4’

  • Bangon Kali Jan 24, 2014 @ 1:11

    Hello, I am unable to find my Kernel Headers by issuing the following commands.

    root@localhost:~/Downloads# apt-get install linux-headers-$(uname -r)
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to locate package linux-headers-3.8.0-00111-g85cc90f
    E: Couldn’t find any package by regex ‘linux-headers-3.8.0-00111-g85cc90f’

    I am using the following Linux based on ARM Arrow SocKit Board.

    Welcome to Linaro 13.04 (GNU/Linux 3.8.0-00111-g85cc90f armv7l)
    root@localhost:~# uname -r

    Any notes on how may I be able to get my Headers?

  • Mettler David Jul 10, 2014 @ 7:54

    Hi there

    Did you find a solution for the header files?

  • Brian Hoskins Aug 31, 2015 @ 5:01

    I broke one of my own rules when I tried this: never try a command suggested on the internet unless you first understand what it does.

    I tried this and it installed linux-headers-3.16.0-4-amd64.

    Then, when I tried to install something else which depends upon the linux-headers to be installed in order to build, it complains that I don’t have the linux headers for my system installed. So it transpires that this command probably caused the wrong ones to be installed.

    So let that be a lesson to me! Don’t break the rules!

    Back to the drawing board!


Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.