Kernel, user space, and distributions
On this page
You want Linux on your computer, so you look for a file to download. Two websites offer one. The home page of kernel.org, where the Linux kernel is published, offers the kernel’s source code as one compressed file of roughly 150 MB. Ubuntu’s download page offers an installation image for Ubuntu Desktop of several gigabytes, dozens of times larger.
Lesson B01.2 said that, strictly, Linux is the kernel. Then what fills the rest of the Ubuntu file? And which of the two files would you install?
By the end of this lesson, you can say what the kernel does alone, what runs around it, and what a distribution adds, and you can answer both questions.
Before you start
Section titled “Before you start”- What an operating system does (B01.1) and Unix, GNU, and Linux (B01.2).
- No computer is needed for this lesson.
What the kernel is
Section titled “What the kernel is”The file on kernel.org holds the kernel’s source code, the text that programmers write (lesson B01.2). It must be translated before the CPU can run it. Once running, the kernel receives the system calls and provides the services from lesson B01.1: scheduling, memory management, files and directories, network connections, device drivers, and permission checks.
The kernel also holds a position that no other program has. The CPU runs code in two modes:
- In kernel mode, code may do anything the hardware allows, such as reading the storage drive directly. The kernel runs in kernel mode.
- In user mode, code may not work with the hardware. It must make a system call, and the kernel does the work if it allows the request.
Every other program runs in user mode. That is how the kernel keeps programs apart.
A kernel with nothing to run
Section titled “A kernel with nothing to run”Guess first: a computer starts the Linux kernel, and there is no other program on its storage. What happens?
Check your guess
The kernel prepares the hardware, then looks in a few fixed places on the storage for the first program to start, called init. When it finds none, it stops with this message, as written in the kernel’s source code:
Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance.A kernel panic means that the kernel has stopped because it cannot continue.
The kernel serves only programs that ask. It does not show a login screen, open a window, or start a text editor; programs outside the kernel do that. Without them, the computer has nothing to do.
User space: every program outside the kernel
Section titled “User space: every program outside the kernel”Everything that runs in user mode, with the memory it uses, is called user space: every program except the kernel. Its main parts are these.
Init and the services. On Ubuntu, init is a program called systemd. Its manual calls it a “system and service manager” that, as the first program, “brings up and maintains userspace services”. A service is a program that runs in the background without a window, usually from startup. One example, systemd-journald, collects the system’s log messages.
System libraries. A library is ready-made code that many programs share. The most important one is the C library; on Ubuntu, the GNU C Library, or glibc. Most system calls have a matching function in it, so a program usually asks the library, and the library makes the system call.
The shell. A shell is a program that reads the commands you type and starts the programs they name. The shell in this course is Bash, from the GNU project. Lesson B03.2 introduces it. A program you start by typing its name in a shell, and that shows its results as text, is called a command-line program.
The desktop. The desktop is the group of programs that draws windows, menus, and icons on the screen and lets you start applications with the mouse. Ubuntu 24.04 uses GNOME 46. Its main program is called GNOME Shell. Despite the name, it draws the desktop; it is not a shell in the sense of this lesson.
Applications. The text editor and the music player from lesson B01.1, or a web browser: the programs you use for your work.
Each of these programs runs in user mode and reaches the hardware only through system calls.
Two ways to start a program
Section titled “Two ways to start a program”A program in user space is started by another program, such as the shell or the desktop.
Guess first: you click the text editor’s icon in the desktop’s list of applications. Does a shell start the text editor?
Check your guess
No. Each application in that list has a small description file, called a desktop entry, that names its program. When you click the icon, the desktop starts that program itself, without a shell. A shell starts a program only when you type its name into the shell.
So there are two paths into user space, and they meet in the same place:
The distribution, for example Ubuntu, contains user space and the kernel. In user space, the shell starts a command-line program and the desktop starts a desktop application. Both applications, like the services, send requests to the system libraries and get results back. The libraries make system calls to the kernel. Below the distribution is the hardware: CPU, memory, storage, and network.
This is a simplified model. Most importantly, the libraries are not a wall that every request must pass: a program can make a system call without the C library, and many library functions never call the kernel. The diagram also leaves out the system calls of the shell, the desktop, and the services, which work the same way.
What a distribution adds
Section titled “What a distribution adds”A distribution is a complete operating system built around the Linux kernel: the kernel and a selected set of user-space programs, prepared to work together, with a way to install and update them and people who maintain them. Ubuntu and Debian are distributions.
A distribution delivers its programs as packages. According to the Debian installation guide, a package contains program files, scripts, documentation, and “configuration information”, meaning settings. Here is what Ubuntu puts around the kernel:
| Part | What it is | In Ubuntu 24.04 LTS |
|---|---|---|
| Kernel | The Linux kernel, built by the distribution from the kernel source code | Linux 6.8 when 24.04 was released |
| System libraries | Shared code that programs use | The GNU C Library and many others |
| Services | Programs that run in the background | systemd and the services it starts |
| Shell | Reads typed commands and starts programs | Bash |
| Desktop | Windows, menus, and icons | GNOME 46, in the Desktop edition |
| Applications | Programs for your work | A web browser, a text editor, and others |
| Package manager | Installs, updates, and removes packages | APT (module B12) |
| Defaults | Choices made for you: which programs are installed, which services start, their settings | Chosen by Ubuntu |
| Support | Fixes for a stated period | Standard security maintenance until May 2029 |
Notice the last two rows: defaults and support are not programs, but decisions and work by the people behind the distribution. LTS means long-term support: five years of standard security maintenance, with security fixes for the packages in Ubuntu’s main collection.
Compare a car. A car maker adds a body, seats, controls, and a service plan to an engine, and different makers build different cars around the same engine. The comparison stops being accurate once you have the system: you can replace almost any part of user space, such as the shell or the desktop, and most parts are free software that you may study and change (lesson B01.2).
Back to the two downloads
Section titled “Back to the two downloads”The file from kernel.org is the kernel’s source code alone. Translated and started, it would look for init and stop.
The much larger file from Ubuntu is a distribution. It contains a kernel ready to run and the rest of the table, as a ready-made system built from Ubuntu’s packages. That is the file you install; module B02 uses it to build your lab.
Security Angle
Section titled “Security Angle”The kernel runs with full control of the hardware, and it enforces both walls from lesson B01.1: between programs in memory, and between accounts on files. So one flaw in the kernel can let a program get past all of them. Two facts decide when such a flaw is fixed on your computer:
- Your kernel comes from your distribution. On Ubuntu, a kernel fix reaches you as an updated kernel package from Ubuntu, during your release’s support period.
- An updated kernel needs a restart. Installing the package does not replace the running kernel; the updated one runs after a restart. Ubuntu’s Livepatch service can fix some kernel flaws while the system runs, but Canonical, the company behind Ubuntu, states that it “is not a replacement for rebooting”.
Try it yourself
Section titled “Try it yourself”Goal: Place each part in the kernel, in user space, or in neither.
- The code that decides which program runs next on the CPU.
- The device driver for a Wi-Fi adapter.
- The GNU C Library.
- systemd.
- Bash.
- Five years of security updates.
Then answer one more question. A friend says: “Programs that I start from the desktop do not use the kernel, because no shell starts them.” What is wrong with this?
Expected: Kernel, user space, or neither for each part, and one or two sentences for the question.
Hint
For each part, ask: does it run with full control of the hardware, in user mode, or is it not a program at all? For the question, look where the two paths in the diagram meet.
Solution
- Kernel. This is scheduling.
- Kernel. Device drivers are part of the kernel.
- User space. It is a system library.
- User space. It is init, the first program the kernel starts, and it starts the services.
- User space. It is the shell.
- Neither. It is support, work that the distribution’s people promise to do. The distribution provides all six, including the kernel it builds.
The friend mixes up what starts a program with how the program reaches the hardware. The desktop starts applications without a shell, and every program in user space, however it was started, reaches the hardware through system calls to the kernel.
- The kernel runs in kernel mode, with full control of the hardware. On its own, it starts, looks for init, and stops if there is none.
- User space is every program that runs in user mode: init and the services, the system libraries, the shell, the desktop, and the applications. They reach the hardware only through system calls.
- A program can be started by the shell or by the desktop. Both paths lead through the same libraries and system calls.
- A distribution packages the kernel and user space together, with a package manager, defaults, and support.
Next, in Choosing a distribution and understanding use cases, you compare distributions and see which one fits which purpose.
Further reading
Section titled “Further reading”- The Linux kernel documentation: What is Linux?; Explaining the “No working init found.” boot hang message; and the
init=entry in The kernel’s command-line parameters, which names/sbin/initas the default first program. The message itself is in the kernel source file init/main.c. - Operating Systems: Three Easy Pieces, the chapter Mechanism: Limited Direct Execution: user mode, kernel mode, and how a system call moves from one to the other.
- Linux manual pages: intro(2), where most system calls have C library functions; libc(7), the C library and glibc; systemd(1), the system and service manager; systemd-journald.service(8), the log service.
- freedesktop.org Desktop Entry Specification: The Exec key, how a desktop entry names the program the desktop starts.
- Debian installation guide: What is GNU/Linux? and What is Debian GNU/Linux?, on the kernel alone, distributions, and packages.
- Ubuntu: Ubuntu 24.04 LTS release notes (Linux 6.8, GNOME 46); Ubuntu release cycle (five years of standard security maintenance); Kernel security and update policy for post-release trees; Automatic updates (restarts after updates); and Livepatch.