'ZDNET Recommends': What exactly does it mean?
ZDNET's recommendations are based on many hours of testing, research, and comparison shopping. We gather data from the best available sources, including vendor and retailer listings as well as other relevant and independent reviews sites. And we pore over customer reviews to find out what matters to real people who already own and use the products and services we’re assessing.
When you click through from our site to a retailer and buy a product or service, we may earn affiliate commissions. This helps support our work, but does not affect what we cover or how, and it does not affect the price you pay. Neither ZDNET nor the author are compensated for these independent reviews. Indeed, we follow strict guidelines that ensure our editorial content is never influenced by advertisers.
ZDNET's editorial team writes on behalf of you, our reader. Our goal is to deliver the most accurate information and the most knowledgeable advice possible in order to help you make smarter buying decisions on tech gear and a wide array of products and services. Our editors thoroughly review and fact-check every article to ensure that our content meets the highest standards. If we have made an error or published misleading information, we will correct or clarify the article. If you see inaccuracies in our content, please report the mistake via this form.
How to compile your first Linux kernel (and 3 reasons why you should)


I remember the first time I compiled a Linux kernel. I was nervous. It was something I'd never done before, and it seemed like an incredibly difficult task. After all, isn't the kernel the stuff of elite programmers? If so, why would I even bother?
Because I could.
Also: These Linux distributions are best for developers
And because all of the cool open-source, alternakids were doing it.
If I wanted to fit in, I had to make (see what I did there?) it happen.
So, I downloaded the kernel source, took a deep breath, and dove in.
This would have been around 2000 or 2001, and when I successfully pulled it off, I'm sure I did a happy dance or two.
But how did I do it?
Believe it or not, the process of compiling the Linux kernel isn't nearly as hard as you might think. It is time-consuming, but it's a challenge you can certainly overcome.
Why would you want to compile the kernel?
There are three reasons why you might want to do this:
- You want to use a newer or different kernel than your distribution provides (such as a real-time or low-latency kernel).
- You need a kernel with very specific configurations and only specific modules.
- You want to brag to your friends that you compiled a Linux kernel.
Also: This is the best-looking Linux desktop of 2025 (so far)
Let me show you how it's done.
How to compile the Linux kernel from source
What you'll need: To compile a kernel, you'll need to download the kernel source, a user with sudo privileges, and plenty of time. I'm going to demonstrate this on an instance of Ubuntu Desktop 24.04. If you're using a distribution not based on Debian or Ubuntu, you'll need to make sure to install the necessary dependencies with your distribution's package manager.
Before you embark on this journey, find a spare machine or deploy a virtual machine. You do not want to compile your first Linux kernel on a production machine.
1. Download the source
The first thing you're going to do is download the source of the kernel you want to use. I would suggest going straight to The Linux Kernel Archives and downloading the tarball file of the kernel you want. I'm going to download the 6.13 source for demonstration purposes.
2. Install the necessary dependencies
Open a terminal window and issue the following command to install the dependencies:
sudo apt-get install build-essential libncurses-dev git bison flex libssl-dev -y
2. Extract the archived file
Open a terminal window and change into the directory housing the downloaded file and extract it with the command:
unxz --keep linux-XXX.tar.xz
Where XXX is the release number.
3. Extract the file
We can now extract the tar file with the command:
tar -xf linux-XXX.tar
Where XXX is the release number.
4. Configuring the kernel
At this point, you can either use the generic configuration or you can manually edit the .conf file within the newly created directory (which will be named linux-XXX – where XXX is the release number). Another method you can use (which I would suggest for your first go-round) is copying your distribution's configuration file.
Before you do this, change into the newly created folder with the command:
cd linux-XXX
Where XXX is the release number.
Next, copy the configuration file with the command:
cp /boot/config-"$(uname -r)" .config
Alternatively, you could manually configure the kernel by using the command:
make menuconfig
The above command opens the menuconfig utility, where you can browse and enable/disable various features. This is how I've always compiled kernels. This method does take some time (because there are a lot of modules to go through). If you go that route, make sure to save it to a file with:
make savedconfig
The above command will create a new directory housing your .config file.
Also: The first 5 Linux commands every new user should learn
5. Update the configuration
After copying the configuration, you need to update the configuration file (because the one shipped with your distribution is most likely out of date). To do this, issue the command:
make oldconfig
The .config file is now updated for the kernel source you downloaded.
6. Disable the signing module
For users of Debian-based distributions, you'll need to disable the module that is used to sign kernel modules, because the certificate used for this is not included. To do this, issue the commands:
scripts/config --disable SYSTEM_TRUSTED_KEYS
scripts/config --disable SYSTEM_REVOCATION_KEYS
If you do not do this, the build will fail later in the process, which means you will have wasted a lot of time (been there, done that...too many times).
7. Building the kernel
It's now time to build the kernel with the command:
make -j$(nproc)
This will take quite a long time to complete.
8. Install the kernel modules
You don’t want every Linux kernel module loading at bootup. Instead, we build loadable modules. This process not only installs the kernel modules but also signs them, which means the process will (once again) take some time. The command for this is:
sudo make modules_install -j$(nproc)
9. (Optional) Install kernel header files
There are some instances when you might need the kernel header files (such as if you were going to write your own modules or install certain server software). For that, issue the command:
sudo make headers_install
10. Install the kernel
It's now time to install the kernel, which is done with the command:
sudo make install
11. Generating the initial ramdisk
The ramdisk (initial RAM filesystem) is required for booting and can be created with:
sudo dracut --force /boot/initrd.img-XXX-generic XXX-generic
Where XXX is the release number of the kernel you're installing.
12. Update grub
Finally, update the grub bootloader (so it's aware of your new kernel) with:
sudo update-grub2
You can now reboot your machine and select the newly compiled kernel.
Also: The best Linux laptops you can buy
Remember, do this on a virtual machine or a test machine because you don't want to monkey around with your daily driver and wind up with a machine that won't boot.
Get the morning's top stories in your inbox each day with our Tech Today newsletter.