To install the kernel source code and headers on an Ubuntu Linux system, you can use the following steps:
sudo apt-get update sudo apt-get install linux-headers-$(uname -r) build-essential
This will install the kernel headers package and the build-essential
package, which includes the tools required to build and install kernel modules.
sudo apt-get install linux-source
This will install the kernel source code in the /usr/src/
directory.
tar -xjf /usr/src/linux-source-4.4.0.tar.bz2 -C /usr/src/
Replace 4.4.0
with the version of the kernel source code you want to extract. This will extract the kernel source code into a directory with the same name as the tarball, without the .tar.bz2
extension.
cd /usr/src/linux-source-4.4.0 make mrproper
This will set up the kernel source code tree, preparing it for building and installing kernel modules.