Linux Kernel
The Linux kernel is the core of the operating system. It manages hardware, memory, processes, and networking, and gives applications controlled access to them through system calls.
Understanding the Linux Kernel
What Does the Linux Kernel Do?
The kernel sits between hardware and software. It schedules which process runs on which CPU, manages memory, talks to disks and network cards through drivers, and enforces permissions. Everything else, including bash, nginx, Docker, and Python, runs on top of it in user space. DevOps engineers touch the kernel constantly through sysctl settings, kernel modules, dmesg, and the /proc and /sys filesystems.
How Kernel Space and User Space Are Separated
The CPU enforces the split: the kernel runs in a privileged mode with full hardware access, while applications run in a restricted mode. They cross the boundary only through system calls such as read and write. This is why a buggy application cannot directly corrupt kernel memory.
Practical Kernel Commands
uname -r # kernel versiondmesg -T | tail -20 # kernel messages with readable timesdmesg -T | grep -i -E 'oom|error|fail' sysctl net.ipv4.tcp_syncookies # read a parametersudo sysctl -w vm.swappiness=10 # change now (lost at reboot) # Persist settingsecho 'vm.swappiness = 10' | sudo tee /etc/sysctl.d/99-custom.confsudo sysctl --system # reload all sysctl files lsmod # loaded modulessudo modprobe br_netfilter # load a moduleecho br_netfilter | sudo tee /etc/modules-load.d/k8s.conf # load at boot cat /proc/cmdline # boot parametersgrep -E 'MemTotal|MemAvailable|SwapTotal' /proc/meminfoTroubleshooting the Kernel
| Symptom | Command | What to Check |
|---|---|---|
| Apps dying unexpectedly | dmesg -T | grep -i oom |
OOM killer activity |
| Module missing | lsmod | grep name |
Load with modprobe |
| High system CPU | top (sy column) |
Time spent in kernel |
| Network tuning | sysctl -a | grep net.ipv4 |
Kernel network settings |
Tip
dmesg -T | grep -i oomis the first command when processes vanish without an application error. The kernel logs which process it killed and how much memory it used.
RememberChanges made with
sysctl -ware temporary. Write them to/etc/sysctl.d/to survive reboot. Kubernetes setups often need persistent values such asnet.bridge.bridge-nf-call-iptables=1.
SecurityOnly load kernel modules from trusted sources. A module runs with full kernel privileges, so a malicious or buggy one can compromise the whole system.
Frequently Asked Questions
How is the kernel/user space split enforced?
The CPU provides privilege levels. Kernel code runs with unrestricted hardware access, and applications run with restricted access. They interact only through system calls, which switch privilege levels in a controlled way.
How is a kernel panic different from an application crash?
An application crash is contained and the kernel cleans up after it. A kernel panic means the kernel itself hit an unrecoverable error, so the whole machine halts and normally needs a reboot.
Is the kernel the same as the operating system?
The kernel is the core of it. A full Linux distribution adds the shell, libraries, package manager, and tools around the kernel.