Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

The Short Answer

The kernel is the core of an operating system. It is the one program that talks to the hardware directly, and every other program asks it for what it needs: memory, time on the processor, access to a file, a network connection. Strictly speaking, Linux is the name of a kernel; a distribution such as Ubuntu or AlmaLinux combines that kernel with tools and packages to make a complete system. See what is Linux.

What the Kernel Does

AreaJob
ProcessesStarts and schedules programs
MemoryGives each process its own space
DevicesDrives disks and network cards
File systemsTurns disk blocks into files
NetworkingTCP/IP, routing, filtering
SecurityPermissions, SELinux, AppArmor

When memory runs out, it is also the kernel that chooses a process to stop; see the OOM killer.

Kernel Space, User Space, and System Calls

The processor runs the kernel in a privileged mode called kernel space. Everything else, from the shell to a database, runs in user space and cannot touch hardware or the memory of other programs. To read a file or open a network socket, a program makes a system call: a request such as open, read, or write that the kernel checks and carries out. A program that crashes in user space takes only itself down; a fault inside the kernel can stop the whole machine.

The strace tool (install the strace package first) counts the system calls a program makes:

strace -c ls /etc

Kernel Modules

Drivers and features that are not always needed are built as modules and loaded when hardware or a feature asks for them:

lsmod
modinfo virtio_net
sudo modprobe br_netfilter

lsmod lists the loaded modules, modinfo describes one, and modprobe loads a module with everything it depends on. Options for modules go in files under /etc/modprobe.d/, and modules to load at every boot are listed in /etc/modules-load.d/.

Find the Kernel Version

uname -r

The output starts with the upstream version number, followed by the distribution's own build number. Other ways, and how to read the number, are in how to check the kernel version in Linux.

Distribution Kernels and Updates

The kernel is developed upstream and published at kernel.org. Distributions do not ship that code unchanged: they pick a version, build it with their own settings, and for the life of a release they carry security fixes back into it instead of moving to each new upstream version. That is why the version number on an Ubuntu LTS or AlmaLinux server can look old while the kernel is fully patched.

A kernel update installs the new kernel next to the running one. It takes effect only after a reboot. The previous kernel normally stays installed, so you can choose it in the boot menu if the new one fails (on a VPS, through the console in your provider's control panel). On Ubuntu, see how to update the kernel in Ubuntu; to restart cleanly, see how to reboot a Linux server. Live patching services can apply some security fixes without a reboot, but they do not replace regular kernel updates.

Kernel Messages and Kernel Panic

The kernel keeps its own log: hardware found at boot, drivers, disk errors, and processes it had to stop. Read it with sudo dmesg or journalctl -k; see the dmesg command. When the kernel meets an error it cannot recover from, it halts with a kernel panic, and the last lines on the console usually name the cause.

Kernels in VMs and Containers

A virtual machine boots its own kernel, so you can choose and update it as on physical hardware; see what is a virtual machine. A container has no kernel of its own: every container on a host uses the host's kernel, and uname -r inside a container prints the host's version. That is why kernel features and limits for containers are set on the host; see what is a container.

Was this answer helpful?
Loading...