Ubuntu: getting back /usr/include/linux

I managed to screw up my /usr/include/linux directory on my Ubuntu system. I knew something was very wrong, because I was trying to compile C code and it was not finding definitions for basic things like EINVAL (which is a standard Unix error that should normally be in /usr/include/linux/errno.h on a proper Linux system). My guess is that this happened while I was working on getting kqemu to build against my kernel. I had mucked around and tried to do things manually instead of using the proper packages. I had symlinked /usr/include/linux to the include/linux directory in my kernel source tree. Not a good idea. That got me files, but the contents were not correct – my /usr/include/linux/errno.h had a fraction of the needed error constants.

It took a while to figure out how to get the directory back, as there are a number of packages related to headers – e.g.: linux-headers-2.6.15-27, linux-headers-2.6.15-27-686. Well, those have a number of headers, but not the ones in /usr/include/linux.

Eventually, I found it:

sudo apt-get install --reinstall linux-kernel-headers

Had I remembered apt-file, I could’ve used that to easily find the package. First, install the package and update its cache:

sudo apt-get install apt-file
sudo apt-file update

and then search for the package containing the file you need:

apt-file search /usr/include/linux/errno.h

Leave a Reply

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