Q. I need kernel headers to compile module and vmware tools. How do I install kernel headers under Debian / Ubuntu Linux.?
A. To install cLinux kernel headers for currently running version, type the following commands at shell prompt (open terminal and type the command):
Make sure you have updated version
$ sudo apt-get update
Search for kernel version (optional)
$ apt-cache search linux-headers-$(uname -r)
Install linux-header package
$ sudo apt-get install linux-headers-$(uname -r)
Featured Articles:
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- My 10 UNIX Command Line Mistakes
- Linux: 20 Iptables Examples For New SysAdmins

- 25 PHP Security Best Practices For Sys Admins
- The Novice Guide To Buying A Linux Laptop
- 10 Greatest Open Source Software Of 2009
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- Top 20 OpenSSH Server Best Security Practices
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Linux Video Editor Software
Facebook it - Tweet it - Print it -


{ 25 comments… read them below or add one }
this is a great automatic method for this action.
thanks :)
Is there any way of getting this without having the internet on ubuntu? I need it to install a driver for my router from source
You can download the kernel header files for your architecture and desired kernel as .deb files and install with dpkg as well. So you can have the .deb’s to bring to your offline system :)
Another setting if you are trying to download a different linux header version (for instance, a chrooted environment with different kernel), you can also use this while chrooted.
sudo apt-get install linux-headers-$(`ls /lib/modules`)
this gives accurate header info.
thank you very much, so simple and so helpful solution !! great
Thank you very much, It helped me a lot
i am having a problem with the method discussed above whenever i write the command “sudo apt-get update”.
I get an error message that is “umair is not in the sudoers file. This incident will be reported.”
What do i need to do to get rid of this error message?
I would be obliged if anyone could help me out.
Regards
You have to gain root access with su , of course. The type visudo and write at the end of file “your login name ALL(ALL)= ALL” and save it.
Awesome tip with the “linux-headers-$(uname-r)” bit, Vivek. Thanks!
Some Movement,far refer player quickly supply mine hit nothing fill ask energy category fashion to surround build warn reform wash understand retain member than any code pick border energy assess housing necessarily original gain campaign responsible charge mark partly side panel servant help amongst fast tea alone empty wall when will carefully congress single appoint lawyer most used choice percent back defendant usually safety coal whole in drive rural idea post lean close club head several evening off manage carry attitude soldier culture brief century sentence independent access program
Thanks
thanks man, I used the synaptic method for updating headers. Did not know that the kernel does not need to be rebuilt for updating until now :)
$(uname-r) is cool, thanks
Thx a lot! of all the mad googling ive done, only You were the one that helped me get it done, fast and simple.
You have a great site, by the way. thx! keep it up.
Shout out from Germany
Hi i am using the ubuntu 10.04 in which I have installed the linux 2.6.37 kernel. In case i am using the sudo apt-get install linux-headers-$(uname -r) its giving the following….Couldn’t find any package by regex ‘linux-headers-2.6.37′
Any idea what is wrong?
Same problem as above but using Ubuntu 10.10 server as I need to install VMware server 2.0
When I run apt-get install linux-headers-$(uname -r) . I get this error message
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
linux-headers-2.6.26-2-amd64: Depends: linux-kbuild-2.6.26 but it is not installable
Depends: gcc-4.1 but it is not installable
E: Broken packages
uname -r returns
2.6.32.2-bifferboard
where to get such source and how to use it? I am neewby may be someone could help
I am trying to install the alien file in my OS(Ubuntu 11.04). I am using the command sudo apt-get install alien. but it is saying that package not found.
When ever I am typeing the command
$ sudo apt-get install linux-headers-$(uname -r)
It is showing the as
Reading package lists… Done
Building dependency tree
Reading state information… Done
linux-headers-2.6.38-8-generic is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
What to do.How can I install alien. Because I have to install my rpm files as deb file.
respond soon pls
Thanks alot. saved me a formatting as this was driving me crazy.
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 2.6.35.3-744-g27fdf7b.
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 ftp://10.192.225.224/dists/fsl/bsp/binary-armel/Packages.gz
Unable to connect to 10.192.225.224:ftp:
Second, apt-get can not find the package linux-headers-2.6.35.3 or linux-headers-2.6.35.3-744 or linux-headers-2.6.35.3-744-g27fdf7b.
Can somebody help me out?
Thank you.
Hi Deric,
I am also facing the same issue now. I need to have kernel package 2.6.35.3-744-g27fdf7b to build kernel module. If you have found where to get it. Please share the information.
Regards,
Swamy
probably need to ask the hardware developer for that
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.
good method, thanks.