A computer or software program contains multiple source files. Many source files need common declarations and functions to operate. Instead of reproducing the same code in each source file, separate files are introduced as an interface between the source files. These files are known as header files. The concept of Linux headers is similar to these header files. The Linux-headers is a package that provides an interface between Kernel internal components, and between Kernel and external memory resources. The kernel is the core program in any Operating System (OS). When an OS boots; Kernel loads after boot loader. It controls various activities including task management, memory management, disk management, etc. For instance, when multiple processes run on an operating system, the Kernel provides uniform resource access to all the running processes. Similarly, the Kernel is responsible for allocating and de-allocating the memory resources to the applications. Since Kernel itself is a program (mostly developed in C language), it also requires memory space to execute the code. The space reserved for Kernel code execution is called the Protected Kernel Space. The protected Kernel space is inaccessible by other applications. The space used by other applications is known as userspace. Therefore, an interface is required between the protected space and the userspace. This interface is provided by the Linux headers.
How to Automatically Install Linux Headers?
Before installing Linux headers, it is important to upgrade the available packages and remove the obsolete ones. First, we need to update the packages list to get information about the latest available versions of the installed packages and dependencies. This can be achieved with the following command.
sudo apt-get update
After updating the packages list, we can download and install the available updates using the dist-upgrade command.
sudo apt-get dist-upgrade
Note: The sudo apt-get upgrade command only upgrades the newest available versions of the installed packages, whereas the sudo apt-get dist-upgrade also removes the obsolete packages from the system.
When the upgrading process completes, reboot the system for the changes to take effect.
After rebooting the system, we can install the Linux-headers package using any of the following commands.
1# sudo apt-get install –y linux-headers-$(uname -r) 2# sudo apt-get install –y linux-headers<-header version>
In the first command, the uname -r parameter fetches the installed Kernel version on the system.
We can manually verify the Kernel version using the following command.
uname -r
sudo apt-get install –y linux-headers-$(uname -r)
We can also search for specific Linux headers using the following command.
sudo apt search linux-headers
After finding the appropriate package, we can install it as follows.
sudo apt-get install –y linux-headers-<linux-headers package here>
For instance, we can install the 5.10.0-kali9-amd64 package using the following syntax.
sudo apt-get install –y linux-headers-5.10.0-kali9-amd64
How to Manually Install Linux Headers?
Besides the automated installation, we can manually install the Linux headers from the following repository.
https://http.kali.org/kali/pool/main/l/linux/
Scroll down the list to find the desired Linux-headers package. Let’s assume we are interested in installing the Linux-headers-5.10.0-kali4-amd64_5.10.19-1kali1_amd64.deb package from the list.
We can install this package with the help of the following command.
sudo dpkg -i linux-headers-5.10.0-kali4-amd64_5.10.19-1kali1_amd64.deb
Summary
The Linux headers play the role of a bridge for many Kernel operations. The Kernel requires the services of Linux headers for protected as well as open memory processes. The upgrading of the existing Kernel version is important for the smooth installation of Linux headers.
Leave a Reply