How to install Kernel Headers

It is important that linux kernel-headers is installed in your system. One reason is that some applications need to use kernel headers like VMWare Workstation, when installing vmware-tools, you will be asked for the path of kernel-headers.

How to install:

First things first, check for updates always. You may miss important updates like kernel update.

sudo apt-get update

To check currently installed kernel.

uname -r

And to install kernel-headers:

sudo apt-get install linux-headers-$(uname -r)

This output is from Kali-Linux.

kernel-headers

UPDATE: If you are having a problem installing kernel-headers, try the additional info given by @jinx from the comment below.

# i'll use nano as my text editor
$ sudo nano /etc/apt/sources.list
# then paste the following lines:
deb http://http.kali.org/ /kali main contrib non-free
deb http://http.kali.org/ /wheezy main contrib non-free
deb http://http.kali.org/kali kali-dev main contrib non-free
deb http://http.kali.org/kali kali-dev main/debian-installer
deb-src http://http.kali.org/kali kali-dev main contrib non-free
deb http://http.kali.org/kali kali main contrib non-free
deb http://http.kali.org/kali kali main/debian-installer
deb-src http://http.kali.org/kali kali main contrib non-free
deb http://security.kali.org/kali-security kali/updates main contrib non-free
deb-src http://security.kali.org/kali-security kali/updates main contrib non-free
deb http://repo.kali.org/kali kali-bleeding-edge main
# CTRL+O to save and then CTRL+X to exit.
# Update repository:
$ sudo apt-get update