How to Install Kernel Headers in Ubuntu [Quick Tips]

Sometimes, when you are compiling an application or packages in your Terminal, you will encounter an error saying “missing kernel header”. This is usually the case when you have just upgraded your kernel and the kernel headers information for the latest kernel is not downloaded to your system. When this happens, you usually won’t be able to compile your packages.

i always have this issue after upgrading to the latest kernel and Virtualbox will always fail everytime I open it. The solution will be to recompile the Vbox kernel module which then lead to the missing kernel header error.

The fix for this is simple. You just have to install (or re-install if you have done so previously) the kernel header for your latest kernel.

1. Open a terminal and type:

sudo apt-get update  #just to make sure that your system is updated 
sudo apt-get install linux-headers-$(uname -r)

This should fetch and install the kernel headers for your latest kernel. That’s it. You should be able to compile your packages without problem now.