Free Linux Kernel Programming Course | Chapter 2
Getting the Linux Kernel Source
Where to find it, how to download it, and what all those version numbers really mean
What You Will Learn
- What kernel.org is and how Linux kernel versions are categorized
- How to download the Linux kernel source using your browser
- How to download using
wgetandcurlfrom the terminal - The difference between stable, LTS, and mainline kernels
- How to read and understand a kernel version number
- Which kernel version is recommended for learning in 2026
Topics Covered
Linux kernel source
LTS kernel
stable kernel
mainline kernel
wget download
curl download
tar.xz tarball
linux kernel programming
free linux kernel course
1. kernel.org — The Official Home of the Linux Kernel
Before you write a single line of kernel code, you need the source. There is exactly one official place to get it: kernel.org. This site is maintained by the Linux Kernel Organization and hosts every version of the kernel ever released — stable releases, long-term support releases, and the bleeding-edge development tree.
When you visit kernel.org, you see a table with many rows of kernel versions. It can look confusing at first. Let’s understand what each row category means before downloading anything.
Linux Kernel Release Categories (as of 2026)
| Category | Who It Is For | Support Duration | 2026 Example |
|---|---|---|---|
| mainline | Kernel developers, early adopters | ~2 to 3 months | 7.1-rc5 |
| stable | General use, desktop and server | A few months | 7.0.x, 7.1.x |
| longterm (LTS) | Embedded systems, enterprise, production | 2 to 6 years | 6.12, 6.18 |
| linux-next | Upstream contributors only | Daily tree, no stability | next-YYYYMMDD |
💡 Which kernel should you learn with?
For learning Linux kernel programming, always pick a stable or LTS kernel. In 2026, either Linux 6.12 or 6.18 is an excellent choice — both are LTS, heavily documented, and have strong community support. The mainline 7.x series is for contributors, not beginners.
2. Understanding Kernel Version Numbers
Linux version numbers follow the pattern MAJOR.MINOR.PATCH. For example, in the version number 6.12.94:
Kernel Version Number Breakdown
| | |
| | +– PATCH level
| | Bug fixes only. Never adds new features.
| | Goes up every time a fix is backported.
| |
| +———- MINOR version
| A new kernel release. Increments roughly
| every 9 to 10 weeks.
|
+—————- MAJOR version
Changes very rarely.
Was 5 for many years, now at 6 and 7.
There is no odd/even numbering trick anymore — that scheme was dropped after version 2.6. Every new release simply increments the minor number. Bug-fix updates like going from 6.12.90 to 6.12.94 never add new features — they only fix things that were already broken.
3. Downloading the Linux Kernel Source
The kernel source is released as a compressed tarball in .tar.xz format. Think of it as a very large ZIP file containing millions of C source files. You have two practical ways to download it.
Method 1 — Download via Browser (Simplest)
Go to kernel.org, find the kernel version you want in the table, and click the [tarball] link next to it. Your browser saves the file, usually to your ~/Downloads folder. This is the easiest method if you just want to get started quickly.
Browser Download — Step by Step
|
Step 2: Find your version in the release table
(pick stable or LTS — avoid mainline for learning)
|
Step 3: Click the [tarball] link next to that version
This starts downloading the .tar.xz file
|
Step 4: File saved to ~/Downloads/linux-VERSION.tar.xz
Size is roughly 130 to 150 MB
Method 2 — Download via Terminal using wget
This is the method every Linux kernel developer should be comfortable with. The terminal lets you script downloads, run them on headless servers, and pick the exact destination path. Here is how to download the LTS kernel 6.12, which is a solid choice for learning in 2026:
# Download Linux 6.12 LTS kernel source
# Update the version number when a newer LTS is available
wget --https-only \
-O ~/Downloads/linux-6.12.tar.xz \
https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.12.tar.xz
What Each Part of the wget Command Does
| Flag or Part | What It Does |
|---|---|
| wget | The download tool. Pre-installed on almost every Linux system. |
| –https-only | Forces HTTPS. Prevents any unencrypted download that could be tampered with in transit. |
| -O ~/Downloads/… | Saves the file with the exact name and path you specify. |
| https://cdn.kernel.org/… | The official kernel CDN. Path pattern: /pub/linux/kernel/vMAJOR.x/linux-VERSION.tar.xz |
Method 3 — Download via Terminal using curl
If wget is not installed (some minimal systems skip it), use curl. It is available on almost every Linux and macOS system by default:
# Download using curl — the -L flag follows any HTTP redirects
curl -L --proto '=https' --tlsv1.2 \
-o ~/Downloads/linux-6.12.tar.xz \
https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.12.tar.xz
✅ wget vs curl — which should you use?
Both tools do exactly the same job here. On Ubuntu or Debian, wget is typically pre-installed. On minimal containers or macOS, curl is more common. Either is perfectly fine for downloading the kernel source.
4. Understanding the kernel.org URL Structure
One thing that confuses beginners is figuring out the correct download URL for a specific kernel version. The pattern is straightforward once you see it:
Kernel Download URL — How It Is Built
https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.12.tar.xzBroken down:
https://cdn.kernel.org/pub/linux/kernel/ — base path (always the same)
v6.x/ — folder for all 6.x series kernels
linux-6.12 — the kernel version (no patch number)
.tar.xz — compressed archive formatFor kernel 7.x the pattern is the same:
https://cdn.kernel.org/pub/linux/kernel/v7.x/linux-7.0.tar.xz
⚠️ Disk Space Warning
The .tar.xz file is roughly 130 to 150 MB. After extraction, the full source tree takes about 1.2 to 1.5 GB. Plan for at least 5 GB free before you start building the kernel itself.
5. What Is Inside the Kernel Source Tree?
After you extract the tarball, you get a folder containing millions of C source files organized into subdirectories. You do not need to understand all of them right now, but knowing the top-level layout helps a lot:
Top-Level Kernel Source Directory Layout
|
+– arch/ CPU architecture code: x86, ARM, RISC-V, MIPS …
| Each CPU family has its own subfolder here.
|
+– drivers/ Device drivers. This is the LARGEST directory.
| USB, PCI, network adapters, GPUs, serial ports …
|
+– kernel/ Core kernel: process scheduler, signals, timers,
| system calls, workqueues, IRQ handling.
|
+– mm/ Memory management: virtual memory, page allocator,
| slab allocator, OOM killer.
|
+– fs/ File system implementations: ext4, btrfs, nfs,
| tmpfs, proc, sysfs …
|
+– net/ Networking stack: TCP/IP, sockets, netfilter,
| wireless, bluetooth.
|
+– include/ Kernel header files used across the entire tree.
|
+– Documentation/ Official kernel documentation. Always read this
| before implementing something new.
|
+– Makefile Top-level build file. This is where builds start.
As a kernel module developer — which is where this free Linux kernel programming course is heading — you will mainly work with include/ headers, look at existing code in drivers/ for reference, and check Documentation/ whenever you need the official spec for a kernel API.
6. Stable vs LTS — Why This Matters for Embedded and Device Driver Developers
This distinction is critical if you are planning to write Linux device drivers or do embedded Linux work. Products in the field often run for years — choosing the wrong kernel base can create serious maintenance problems down the road.
Stable vs LTS Kernel — Key Differences
| Aspect | Stable Kernel | LTS Kernel |
|---|---|---|
| Support Period | 3 to 4 months | 2 to 6 years |
| New Features | Yes, every release cycle | No — security patches and bug fixes only |
| Used By | Desktop users, general servers | Android, embedded systems, enterprise products |
| Risk Level | Higher — new code, less field-tested | Lower — conservative changes, heavily tested |
Android, for example, is always built on an LTS kernel base. The Android kernel team takes an LTS snapshot and applies their device-specific patches on top. If you are developing a product that will ship to customers, an LTS kernel underneath is not optional — it is a requirement.
📋 Key Takeaways — Lecture 6
#128203; Key Takeaways — Lecture 6
- The only official source for Linux kernel code is kernel.org
- Kernel version format is MAJOR.MINOR.PATCH — patch level is bug fixes only
- For learning or embedded work, always choose an LTS kernel (6.12 or 6.18 in 2026)
- Download via browser (click tarball) or terminal (
wgetorcurl) - The compressed download is ~130 MB; extracted source is ~1.4 GB
- URL pattern:
https://cdn.kernel.org/pub/linux/kernel/vMAJOR.x/linux-VERSION.tar.xz
🎯 Interview Questions — Linux Kernel Source
#127919; Interview Questions — Linux Kernel Source
Q1. Where do you get the official Linux kernel source code?
Answer: The official and only authoritative source is kernel.org, maintained by the Linux Kernel Organization. It hosts all release types including mainline, stable, LTS, and the linux-next integration tree.
Q2. What is the difference between a stable kernel and an LTS kernel?
Answer: A stable kernel is maintained for only a few months until the next release cycle. An LTS kernel is maintained for 2 to 6 years and receives only critical bug fixes and security patches — never new features. Production systems, Android devices, and embedded products use LTS kernels because the long support window matches their deployment lifecycle.
Q3. What does the version number 6.12.94 mean?
Answer: It follows MAJOR.MINOR.PATCH format. 6 is the major version, 12 is the minor version (a new kernel release, increments every ~10 weeks), and 94 is the patch level — the 94th bug-fix update to the 6.12 kernel. Patch releases never add new features.
Q4. What format is the kernel source distributed in and why?
Answer: The source is distributed as a .tar.xz file — a tarball compressed with the XZ algorithm. XZ provides excellent compression, which is why the entire 1.4 GB source tree fits into roughly 130 MB for download.
Q5. What is the linux-next tree and who should use it?
Answer: linux-next is a daily integration tree where patches from all kernel subsystem maintainers are merged together before they enter Linus Torvalds’ mainline tree. It has no stability guarantee and may not even compile on a given day. Only developers actively submitting patches upstream should use it. Learners and product developers must stay on stable or LTS kernels.
Q6. Why must you use HTTPS when downloading the kernel source?
Answer: The kernel source is code you will compile and run with full privileges on your machine. A man-in-the-middle attacker could inject malicious code into a plain HTTP download without detection. HTTPS encrypts the connection. The --https-only flag in wget enforces this. Kernel releases are also GPG-signed for additional verification.
Q7. Name the key top-level directories in the kernel source and what they contain.
Answer: arch/ — CPU architecture code (x86, ARM, RISC-V). drivers/ — all device drivers, the largest directory. kernel/ — core functions: scheduler, signals, timers. mm/ — memory management. fs/ — file system implementations. net/ — networking stack. include/ — header files. Documentation/ — official kernel documentation.
Continue the Free Linux Kernel Programming Course
Next lecture covers Git clone and extracting the kernel source tree — hands-on terminal work.
