Linux Internals

What Is the Kernel? The Core of Linux Explained

By NileVPS Team · Published · 5 min read

اقرأ المقال بالعربي

Every time a web server accepts a connection, a database writes a page to disk or a script reads a file, something has to talk to the hardware on its behalf. That something is the kernel. It is the one program that is always running on a Linux server, sitting between your applications and the CPU, memory, disks and network. You rarely interact with it directly, yet almost every performance question and many outages trace back to how it behaves. This article explains what the kernel does, how programs talk to it, and the practical commands for inspecting and maintaining it on a VPS.

The kernel's job in one sentence

The kernel decides who gets to use which hardware, when, and how much, while keeping programs from interfering with each other. "Linux" strictly refers to this kernel; the shell, systemd, package manager and tools around it come from the distribution.

Its main responsibilities are:

  • Process scheduling: choosing which thread runs on each CPU core and for how long.
  • Memory management: giving each process its own virtual address space, mapping it to physical RAM, caching files and reclaiming memory under pressure.
  • Filesystems and storage: turning open() and write() into blocks on a disk through drivers such as ext4, XFS and virtio-blk.
  • Networking: the full TCP/IP stack, firewall hooks (netfilter, used by nftables and iptables) and socket buffers.
  • Device drivers: code that speaks to virtual or physical hardware.
  • Security and isolation: users and permissions, namespaces and cgroups (the building blocks of containers), and modules such as SELinux or AppArmor.

Kernel space and user space

The CPU runs in different privilege levels. The kernel runs in kernel space with full access to hardware and all memory. Your applications run in user space, where they can only touch their own memory and cannot talk to devices directly.

This split is the reason one buggy application does not take down the whole server, and the reason a bug inside the kernel can. When kernel code fails badly, the result is a kernel panic rather than a single crashed process.

System calls: how programs ask for help

When a program needs something only the kernel can provide, it makes a system call: read, write, openat, socket, accept, mmap, clone and a few hundred others. The CPU switches into kernel mode, the kernel does the work, and control returns to the program.

You can watch this happen with strace:

sudo apt install strace     # or: sudo dnf install strace
strace -c ls /etc > /dev/null

The -c flag prints a summary of which system calls were made and how much time they took. On a busy server, a program making millions of small system calls can spend a noticeable share of its CPU time crossing into the kernel, which is why buffering and batching matter.

Processes, threads and the scheduler

To the kernel, every runnable unit is a task. Processes and the threads inside them are both scheduled by the same scheduler, which tries to share CPU time fairly while keeping interactive work responsive. On a VPS you share physical cores with the hypervisor's scheduling as well, which is why the st (steal) column in top exists. For more on how this affects application design, see threads vs processes.

Inspecting the kernel on your server

These commands answer most everyday questions:

CommandWhat it tells you
uname -rRunning kernel version
cat /proc/cmdlineBoot parameters passed to the kernel
lsmodLoaded kernel modules
modinfo <module>Details about one module
dmesg -T or journalctl -kKernel log messages with timestamps
sysctl -aAll tunable kernel parameters
ls /bootInstalled kernel images and initramfs files

The /proc and /sys directories are not real files on disk. They are windows into the kernel's live state: /proc/meminfo shows memory accounting, /proc/loadavg the load average, and /sys/block/ your disks.

Tuning with sysctl

Many kernel behaviours are adjustable at runtime. For example, to view and change how eagerly Linux swaps:

sysctl vm.swappiness
sudo sysctl -w vm.swappiness=10

Changes made with -w are lost on reboot. To make them permanent, put them in a file:

echo "vm.swappiness = 10" | sudo tee /etc/sysctl.d/99-custom.conf
sudo sysctl --system

Change one setting at a time and measure. Copying long lists of "optimised" values from the internet often does more harm than good.

Kernel modules

Not everything is built into the kernel image. Drivers and features such as WireGuard, specific filesystems or netfilter helpers are often loadable modules:

sudo modprobe wireguard
lsmod | grep wireguard

Modules run in kernel space with full privileges, so only load ones from your distribution or sources you trust.

Updating the kernel safely

Kernel updates fix security issues and bugs, but a new kernel only takes effect after a reboot. A safe routine:

  1. Take a snapshot of the VPS.
  2. Update packages: sudo apt update && sudo apt full-upgrade or sudo dnf upgrade.
  3. Check that /boot has free space and that a new image appeared in ls /boot.
  4. Reboot during a quiet window, keeping the browser console open.
  5. Confirm with uname -r, then check that your services started: systemctl --failed.

Keep the previous kernel installed so you can pick it from the GRUB menu if the new one misbehaves.

FAQ

Is the kernel the same thing as the operating system?

Not exactly. The kernel is the core that manages hardware and resources. An operating system such as Ubuntu or Rocky Linux bundles the kernel with an init system, libraries, a shell, a package manager and many tools. People often use "Linux" for both, but technically it names only the kernel.

Can I change the kernel on a VPS?

On a KVM-based VPS, which is the common model today, the server boots its own kernel, so you can install another version from your distribution's repositories and select it at boot. Container-based virtualization works differently, since all containers share the host's kernel.

Do I always need to reboot after a kernel update?

The new kernel runs only after a reboot. Live-patching services can apply some security fixes without rebooting, but they cover selected issues rather than full upgrades, so a planned reboot is still needed from time to time.

Related guides