The kernel is the core of a Linux system. It is the program that controls the hardware and shares it among everything else that runs. Strictly speaking, "Linux" is the name of this kernel. A distribution adds a shell, libraries, tools and applications around it.
Two sides of the system
Memory and execution are split into two areas. The kernel runs in kernel space with full control of the machine. Your programs, including the shell, run in user space with limited rights. When a program needs something protected, such as reading a file, it asks the kernel through a system call.
What the kernel manages
- Processes: it creates them and the scheduler decides which one runs on each CPU.
- Memory: it gives each process its own virtual address space and can move some pages to swap.
- Devices: drivers let it talk to disks, network cards and keyboards.
- Filesystems: it turns files and directories into data on storage.
- Networking: it implements protocols such as IP and TCP.
How it is built
Linux is a monolithic kernel: drivers, filesystems and the network stack run in kernel space. It is also modular. Many parts can be built as modules and loaded only when needed, without a reboot.
Look at your kernel
uname -r6.8.0-45-genericThe number starts with the version of the upstream kernel. The suffix is added by whoever built it, so yours will look different. A distribution kernel can contain fixes carried back from newer releases, so the version number alone does not tell you which fixes are included.
uname -srm
cat /proc/versionLinux 6.8.0-45-generic x86_64
Linux version 6.8.0-45-generic (builder@host) (gcc ...) #1 SMP ...The kernel also writes messages about hardware and errors into a log:
sudo dmesg | headSome systems let ordinary users run dmesg, and others require root.
A container does not have its own kernel. It uses the kernel of the host, so uname -r inside a container reports the host's version. A virtual machine runs its own kernel.
To see processes that the kernel is scheduling, try the processes lab.
Try it
- Run
uname -randuname -mto find your version and machine type. - Run
cat /proc/meminfo | head -n 5to see the kernel's view of memory. - Run
ps -e | headto list some processes. - Run
sudo dmesg | lessand look for lines about your disk or network card. Pressqto quit.
Check your understanding
Overview of the kernel
All 4 sections ยท no timer
Unlimited retries
Questions from every section are combined into one assessment. Answer them all correctly to complete the article.
Your completion saves in this browser. Sign in to sync it to your account.