What is the difference between kernel space and user space?
In one line: Kernel space is where the Linux kernel runs with full control of the hardware. User space is where normal programs run, with limited permissions.
Simple analogy: in a bank, customers (user space programs) can't walk into the vault (hardware and memory). They ask the cashier (the kernel) to do it for them through a counter window. Those requests are called system calls.
Why the split matters:
- Safety: if a normal program crashes, only that program dies. If code in kernel space crashes, the whole machine can go down (a "kernel panic").
- Security: programs can't read other programs' memory or touch the hardware directly.
Example — watch a program making system calls:
strace -c ls /tmp # summary of the system calls ls made
strace -e openat cat /etc/hostname # show only file-open calls
You'll see calls like openat, read and write — every time a program reads a file or sends data over the network, it asks the kernel through a system call.
DevOps connection: containers share the host's kernel. That's why a container image doesn't include its own kernel, and why kernel-level issues affect every container on that node.