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'm currently reading Operating System Concepts 7th edition by Silberschartz, Galvin and Gagne. At the end of chapter 2, there is an exercise "Add a system call to the Linux Kernel". Unfortunately, I realized the directory structure that the authors used is completely different with Ubuntu's one. For example, the authors referred to "/usr/src/linux-2.x/include/asm-i386/unistd.h", but on my machine, they are:

  • /usr/src/linux-headers-2.6.38-10
  • /usr/src/linux-headers-2.6.38-10-generic

And inside this folder, I couldn't find anything called "asm-i386" :(. I wonder is there a documentation specified for Ubuntu? Any suggestion would be greatly appreciated.

Thank you,

share|improve this question
up vote 4 down vote accepted

Ubuntu doesn't do anything special. Your first difficulty is that you don't have the kernel source installed, only kernel headers. The authors are describing a system with a copy of the kernel source in /usr/src/linux-2.x. If you're only compiling external modules, the headers, which are what you see on your system, are enough. Ubuntu ships kernel headers for that purpose in the linux-headers-* packages (which you would normally install via the dependency from the linux-headers-generic Install linux-headers-generic metapackage). If you need the whole source, get a compressed archive from the linux-source-2.6 Install linux-source-2.6 binary package.

Another thing is that the directory structure has changed a little over time; architecture-dependent headers moved from include/asm-$ARCH to arch/$ARCH/include/asm. Furthermore the i386 and x86_64 architectures were merged into a unified x86 in 2.6.24. (More details here.) So you now need to look in arch/x86/include rather than include/asm-i386.

Here are a few useful resources for Linux kernel hackers:

  • Linux Device Drivers (LDD3)
  • LWN (news about Linux, including many technical articles about the kernel by one of the authors of LDD)
  • LXR to browse and search the kernel source
  • LKML (the Linux kernel mailing list), Stack Overflow to ask questions about the kernel and kernel development

And also read this thread on Unix & Linux, which explains how to locate the implementation of an existing syscall.

share|improve this answer
Nice answer! I just ran find /usr/src -type f -name unistd.h for my answer :) – Xiao-Long Chen Jul 13 '11 at 23:01
@Gilles: I was a bit confused with the author's instruction. Thank you so much for your help. – Chan Jul 14 '11 at 4:48


or in future kernels:



share|improve this answer

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.