Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i want to write a device driver but not able to find the header file can someone please help me find them?Also if someone can point out some important site links that would be really appreciated

share|improve this question
up vote 78 down vote accepted

You should be able to install the kernel header files for the currently running kernel by running the following in a terminal:

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

In general, the kernel header packages are named linux-header-* where "*" indicates the version & variant (generic, server, etc.).

share|improve this answer
hey thanks but could you tell me what does generic, server, etc means i want to write (kernel driver) – coder Nov 6 '11 at 3:39
This won't install the headers for future updates automatically and you'll have to re-run this command every time. Therefore, it's recommended to install the metapackage instead, as described in another answer. – gertvdijk Jun 25 '13 at 21:13
Note: this doesn't put them in the GCC include path, you still need -I. – Ciro Santilli 巴拿馬文件 六四事件 法轮功 Aug 8 '15 at 7:34

You can just type:

sudo apt-get install linux-headers-generic

if you are on a Desktop installation. The apt-get will solve the dependencies and install the correct version of kernel headers.

share|improve this answer
and Ubuntu will also update them when a new version comes out – Csq May 5 '13 at 7:38
Or linux-headers-virtual if your running a VM in an Openstack instance... – BSchlinker Sep 18 '13 at 6:41
In Debian Wheezy I get the error message "Package linux-headers-generic is not available, but is referred to by another package. [...] E: Package 'linux-headers-generic' has no installation candidate" – IQAndreas Apr 27 '15 at 3:10
@IQAndreas the linux-headers-generic package is ubuntu specific. On Debian you should use sudo apt-get install linux-headers-$(uname -r) – Alexandre Teles Apr 28 '15 at 16:00

This should cover another problem when: the running kernel is obsolete, meaning it's not in the repository anymore neither its headers. So the best thing to do is to update the kernel to last version in the repository.

linux-generic is a meta package to keep current version of the kernel & its headers:

sudo apt-get update
sudo apt-get install linux-generic

Note: Depending on your Ubuntu edition, See if you need linux-lowlatency (Ubuntu Studio), linux-signed-generic or linux-virtual.

share|improve this answer
None of the other solutions worked for me when trying to install a driver. Thanks you. – Sopalajo de Arrierez Jan 5 at 3:33

Or if you have aptitude installed: sudo aptitude install linux-headers-$(uname -r)

share|improve this answer
Essentially the same thing. – IAnsari Sep 28 '15 at 11:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.