Ravindra BagaleCourses & study guides मराठी Track your progress

AWS Cloud

Linux Kernel Basics: Modules, /proc, /sys, Namespaces and cgroups (How Containers Work)

The kernel is the core of Linux. It talks to hardware, runs processes and keeps them apart. In this chapter you will see the kernel version, load and unload kernel modules (drivers), read live kernel data in /proc and /sys, and learn the two features that make containers possible: namespaces (what a process can see) and cgroups (how much it can use). After this, Docker and Kubernetes will stop feeling like magic.

In this chapter

  • Check kernel version and boot parameters
  • List, load and blacklist modules
  • Read process and system data in /proc and /sys
  • Create namespaces with unshare and enter with nsenter
  • Limit CPU and memory with cgroups v2 and systemd
  • Connect it all to containers

1. An everyday example: a co-working space

A co-working building in Baner has one manager (kernel). Each company gets its own cabin: they see only their own name board, Wi-Fi name and staff list (namespaces). The meter limits how much power and AC each cabin uses (cgroups). When a new printer arrives, the manager plugs in its driver (module). The notice board in the lobby shows live stats for everyone (/proc).

Manager = kernel. Driver for the printer = module. Lobby board = /proc and /sys. Private cabin view = namespaces. Power meter = cgroups. Cabin = container.

How a container startsRuntime asks kernel for new namespaces (pid, net, mnt, uts, ipc, user)Kernel creates a cgroup and sets CPU/memory limitsRoot filesystem (image layers) is mountedProcess starts as PID 1 insideIt sees only its own world
A container is just a normal process with namespaces and cgroups.

2. Kernel version and boot options

Bugs, drivers and features depend on the kernel version.

uname -r prints the running kernel; uname -a shows all. /proc/cmdline shows boot parameters. Installed kernels: rpm -q kernel or dpkg -l 'linux-image*'. grubby --info=ALL (RHEL) shows boot entries. A new kernel needs a reboot.

  1. Running kernel.
uname -r

Output:

6.1.112-124.190.amzn2023.x86_64

Amazon Linux 2023.

  1. Boot parameters.
cat /proc/cmdline

Output:

BOOT_IMAGE=(hd0,gpt1)/vmlinuz-6.1.112 root=UUID=... ro console=ttyS0

Passed by GRUB.

  1. Add a boot option.
sudo grubby --update-kernel=ALL --args='mitigations=auto'

Output:

(no output)

Applies next boot.

3. Kernel modules: lsmod and modinfo

Drivers for disks, network cards and filesystems are modules loaded on demand.

lsmod lists loaded modules with size and users. modinfo NAME shows description, version and parameters. Modules live in /lib/modules/$(uname -r). lspci -k shows which driver a device uses.

  1. Loaded.
lsmod | head -4

Output:

Module   Size  Used by
ena    151552  0
nvme    53248  2

ENA network, NVMe disk.

  1. Details.
modinfo ena | head -4

Output:

filename: /lib/modules/6.1.../ena.ko.xz
description: Elastic Network Adapter (ENA)
version: 2.12.0g

AWS network driver.

  1. Device driver.
lspci -k | grep -A2 -i ethernet

Output:

00:05.0 Ethernet controller: Amazon.com ENA
 Kernel driver in use: ena

Confirms.

4. modprobe: load, unload, blacklist

You need a module for WireGuard, an extra filesystem, or to stop a buggy driver.

modprobe NAME loads with dependencies; modprobe -r unloads. Load at boot: file in /etc/modules-load.d/NAME.conf. Options: /etc/modprobe.d/NAME.conf with 'options NAME key=val'. Blacklist: 'blacklist NAME' in /etc/modprobe.d. Avoid insmod/rmmod (no dependency handling).

  1. Load.
sudo modprobe br_netfilter && lsmod | grep br_netfilter

Output:

br_netfilter 32768 0
bridge 315392 1 br_netfilter

Needed by Kubernetes.

  1. At boot.
echo br_netfilter | sudo tee /etc/modules-load.d/k8s.conf

Output:

br_netfilter

Persistent.

  1. Blacklist.
echo 'blacklist floppy' | sudo tee /etc/modprobe.d/no-floppy.conf

Output:

blacklist floppy

Not loaded again.

  1. Unload.
sudo modprobe -r floppy

Output:

(no output)

Removed if unused.

5. dmesg: kernel messages

Hardware errors, OOM kills and driver problems show here first.

dmesg -T shows readable times; -l err,warn filters level; -w follows live. journalctl -k does the same from the journal, and -k -b -1 shows the last boot.

  1. Errors only.
sudo dmesg -T -l err,warn | tail -3

Output:

[Sun Oct 25 20:10] EXT4-fs warning (device nvme1n1): ...

Disk warning.

  1. Last boot.
journalctl -k -b -1 | tail -2

Output:

kernel: Out of memory: Killed process 912 (node)

Why it crashed.

  1. Live.
sudo dmesg -w

Output:

[ 9912.1] usb 1-1: new device

Plug and watch.

6. /proc: live process and system data

Open /proc as a live view exposed by the kernel. Many entries look like files and are generated when you read them. A numbered directory belongs to a process ID. In your shell, read selected lines from /proc/$$/status and compare Name and Pid with ps. $$ is expanded by the shell to its PID. Start a short disposable process, watch its numbered entry appear and confirm it disappears after the process exits. That explains why a path you saw a moment ago can go missing.

Every tool like ps, top and free reads /proc. You can read it directly.

System files: /proc/cpuinfo, /proc/meminfo, /proc/loadavg, /proc/mounts, /proc/sys (tunables). Per process /proc/PID: cmdline, environ, status (memory, state), fd/ (open files), limits, cwd, exe, ns/ (namespaces), cgroup.

  1. CPU model.
grep -m1 'model name' /proc/cpuinfo

Output:

model name : Intel(R) Xeon(R) Platinum 8259CL

Instance CPU.

  1. Process memory.
grep -E 'VmRSS|State' /proc/3011/status

Output:

State: S (sleeping)
VmRSS: 1983420 kB

~1.9 GB.

  1. How it was started.
tr '\0' ' ' < /proc/3011/cmdline

Output:

java -Xmx2g -jar shop.jar

Full command.

  1. Deleted but open file.
sudo ls -l /proc/3011/fd | grep deleted

Output:

9 -> /var/log/shop.log (deleted)

Space not freed until restart.

7. /sys: devices and kernel objects

/sys exposes devices, block queues and module parameters as files.

/sys/block/DISK/queue/scheduler shows the I/O scheduler. /sys/class/net/IF/ has speed and statistics. /sys/module/NAME/parameters shows module options. /sys/fs/cgroup is the cgroup tree. Writing to some files changes behaviour live.

  1. I/O scheduler.
cat /sys/block/nvme0n1/queue/scheduler

Output:

[none] mq-deadline kyber

none for NVMe.

  1. Interface counters.
cat /sys/class/net/ens5/statistics/rx_dropped

Output:

15422

Drops.

  1. Module option.
cat /sys/module/nvme_core/parameters/io_timeout

Output:

4294967295

EBS needs a high value.

8. Namespaces: what a process can see

A namespace changes the view a process has of one kind of resource. A PID namespace can give processes their own numbering. A network namespace can give them their own interfaces and routes. In the network namespace lab, list interfaces on the host and in the namespace. Compare the results instead of assuming the host’s internet route is available inside. The host still runs these processes under the same kernel. This gives a first picture of how containers can have separate views on one Linux machine.

Namespaces isolate containers from each other and from the host.

Types: pid (process IDs), net (interfaces, ports), mnt (mounts), uts (hostname), ipc, user (UID mapping), cgroup, time. lsns lists them. ls -l /proc/PID/ns shows a process's namespaces. unshare creates new ones; nsenter enters existing ones; ip netns manages network namespaces.

NamespaceIsolatesContainer effect
pidProcess IDsApp is PID 1
netNetwork stackOwn IP and ports
mntMountsOwn root filesystem
utsHostnameOwn hostname
userUser IDsRoot inside, normal outside
  1. List.
sudo lsns -t net

Output:

NS         TYPE NPROCS PID  COMMAND
4026531840 net  210    1    /usr/lib/systemd/systemd
4026532301 net  2      8812 nginx: master

nginx in a container.

  1. New hostname world.
sudo unshare --uts --fork bash -c 'hostname box-a; hostname'

Output:

box-a

Host name unchanged outside.

  1. New PID world.
sudo unshare --pid --fork --mount-proc bash -c 'ps -e'

Output:

PID TTY TIME CMD
  1 pts/0 00:00:00 bash
  2 pts/0 00:00:00 ps

Bash is PID 1.

  1. Enter a container's network.
sudo nsenter -t 8812 -n ss -ltn

Output:

LISTEN 0 511 0.0.0.0:80

Debug without tools in the image.

9. Network namespaces with ip netns

This is exactly how Docker bridges and Kubernetes pods get networking.

ip netns add NAME creates one. A veth pair is a virtual cable: one end in the host, one in the namespace. Give IPs, bring links up, and ping. ip netns exec NAME CMD runs a command inside.

  1. Create.
sudo ip netns add red && sudo ip link add veth-h type veth peer name veth-r && sudo ip link set veth-r netns red

Output:

(no output)

Cable plugged.

  1. Address.
sudo ip addr add 10.9.0.1/24 dev veth-h && sudo ip link set veth-h up && sudo ip netns exec red ip addr add 10.9.0.2/24 dev veth-r && sudo ip netns exec red ip link set veth-r up

Output:

(no output)

Both ends up.

  1. Ping.
sudo ip netns exec red ping -c1 10.9.0.1

Output:

1 packets transmitted, 1 received

Works.

10. cgroups v2: how much a process can use

A control group collects processes so Linux can measure or limit their resource use together. For a training job, the computer may still have spare RAM while the group is near its assigned limit. Read the service’s current memory use and the group’s memory.max separately. Compare those numbers with the whole machine’s RAM. CPU weight gives a share when groups compete for CPU time. A CPU quota sets a time budget over a period. Those settings answer different questions about how much work the group can do.

Without limits one runaway process can eat all CPU or memory and kill the server.

cgroup v2 is one tree at /sys/fs/cgroup. Check: stat -fc %T /sys/fs/cgroup prints cgroup2fs. Each group has files: memory.max, memory.current, cpu.max ('quota period', e.g. 50000 100000 = half a CPU), pids.max, io.max. Put a PID in cgroup.procs. memory.events counts OOM kills.

  1. Version.
stat -fc %T /sys/fs/cgroup

Output:

cgroup2fs

v2.

  1. Make a group by hand.
sudo mkdir /sys/fs/cgroup/demo && echo 200M | sudo tee /sys/fs/cgroup/demo/memory.max && echo '50000 100000' | sudo tee /sys/fs/cgroup/demo/cpu.max

Output:

200M
50000 100000

200 MB, half a CPU.

  1. Move shell in.
echo $$ | sudo tee /sys/fs/cgroup/demo/cgroup.procs

Output:

2241

Children are limited too.

  1. Which cgroup?
cat /proc/3011/cgroup

Output:

0::/system.slice/shop-api.service

systemd made it.

11. cgroups the easy way: systemd

systemd already puts every service in a cgroup, so set limits there instead of by hand.

In a unit or drop-in: MemoryMax=1G, CPUQuota=150%, TasksMax=500, IOWeight=. Live: systemctl set-property UNIT MemoryMax=1G. One-off: systemd-run --scope -p MemoryMax=300M CMD. Watch with systemd-cgtop; tree with systemd-cgls.

  1. Limit a service.
sudo systemctl set-property shop-api.service MemoryMax=1G CPUQuota=150%

Output:

(no output)

Persisted in a drop-in.

  1. One-off job.
sudo systemd-run --scope -p MemoryMax=300M -p CPUQuota=50% tar czf /backup/www.tgz /var/www

Output:

Running scope as unit: run-r1b2.scope

Backup cannot hog.

  1. Live top per cgroup.
systemd-cgtop -n 1

Output:

Control Group             Tasks %CPU Memory
/system.slice/shop-api    88    140  980M

Near the limit.

  1. Docker uses the same.
docker run -d --memory 512m --cpus 1.5 nginx

Output:

f3a1...

cgroup limits.

12. Putting it together: a container from scratch

Seeing it once by hand removes the mystery of containers.

Combine unshare (pid, mnt, uts, net), a root filesystem (an extracted image), chroot, and a cgroup limit. Real runtimes (runc, containerd) do the same plus seccomp, capabilities and overlay filesystems.

  1. Get a root filesystem.
mkdir rootfs && docker export $(docker create alpine) | tar -x -C rootfs

Output:

(no output)

Alpine files.

  1. Start a mini container.
sudo unshare --pid --uts --mount --net --fork chroot rootfs /bin/sh -c 'mount -t proc proc /proc; hostname mini; ps; hostname'

Output:

PID USER COMMAND
 1 root /bin/sh -c ...
mini

Own PIDs and name.

  1. Container PID on host.
docker inspect -f '{{.State.Pid}}' web

Output:

8812

Just a host process.

13. Real examples from many industries

The same Linux skill shows up in every kind of company. Seeing it in many places helps you remember it.

Each row is a made-up team. It shows who uses this and how.

Team and cityHow they use itCommand
Aniket, Kubernetes platform, PuneLoads br_netfilter and overlaymodprobe overlay
Sophie, CI service, Parissystemd-run limits for build jobssystemd-run --scope -p MemoryMax=2G
Hiro, telecom, TokyoNetwork namespaces for test labsip netns add
Fatima, bank, DohaBlacklists unused USB storageblacklist usb-storage
Carlos, video, Mexico Citycgroup CPU caps for encodersCPUQuota=200%
Pooja, SaaS, Bengalurunsenter to debug podsnsenter -t PID -n

14. Common errors and how to fix them

Everyone hits these errors. Knowing the cause saves hours.

Read the exact message first. Then match it to a row below.

Error you seeWhy it happensHow to fix
modprobe: FATAL: Module wireguard not found in directory /lib/modules/...Module not built for this kernelInstall kernel-modules-extra or matching package.
sudo dnf install -y kernel-modules-extra
modprobe: FATAL: Module nvme is in useDevice still using itDo not unload in-use drivers.
lsmod | grep nvme
Required key not availableSecure Boot rejects unsigned moduleUse signed modules or enroll a key.
mokutil --sb-state
unshare: unshare failed: Operation not permittedNot root and user namespaces offUse sudo or --user --map-root-user.
sysctl user.max_user_namespaces
tee: memory.max: No such fileController not enabled in parentAdd +memory to cgroup.subtree_control.
cat /sys/fs/cgroup/cgroup.subtree_control
Container OOMKilled (exit 137)Hit memory.maxRaise limit or fix the leak.
cat /sys/fs/cgroup/system.slice/*/memory.events
Cannot open /proc/PID/...: No such fileProcess already exitedRe-check the PID.
pgrep -f shop
Failed to set unit properties: Unit not loadedWrong unit nameUse the full name with .service.
systemctl list-units --type=service | grep shop
rmdir: failed to remove 'demo': Device or resource busycgroup still has processesMove or kill them first.
cat /sys/fs/cgroup/demo/cgroup.procs
Disk full but du shows littleDeleted file still openRestart the holder or truncate via /proc.
sudo lsof +L1

15. Troubleshooting step by step

For kernel-level issues: read messages, then check the right file.

Go top to bottom. Stop at the first step that shows the problem.

  1. Kernel log
sudo dmesg -T -l err,warn
  1. Loaded drivers
lsmod
  1. Device and driver
lspci -k
  1. Process details
cat /proc/PID/status
  1. Namespaces
sudo lsns
  1. cgroup limits
systemctl show UNIT -p MemoryMax -p CPUQuotaPerSecUSec

16. Lab 1: Modules and /proc

Load a module at boot and read a process's details from /proc.

A full hands-on lab. Run every step on a test Linux machine (an EC2 instance, a VM, or WSL).

  1. Info.
modinfo overlay | head -3

Output:

description: Overlay filesystem
  1. Load.
sudo modprobe overlay && lsmod | grep overlay

Output:

overlay 151552 0
  1. Persist.
echo overlay | sudo tee /etc/modules-load.d/overlay.conf

Output:

overlay
  1. Start a process.
sleep 600 &

Output:

[1] 7001
  1. Read it.
grep -E 'State|PPid' /proc/7001/status; ls -l /proc/7001/ns | head -3

Output:

State: S (sleeping)

17. Lab 2: Namespaces and cgroups

Make an isolated shell and a memory-limited job.

A full hands-on lab. Run every step on a test Linux machine (an EC2 instance, a VM, or WSL).

  1. PID namespace.
sudo unshare --pid --fork --mount-proc bash -c 'ps -e'

Output:

1 bash
  1. UTS namespace.
sudo unshare --uts --fork bash -c 'hostname lab; hostname'

Output:

lab
  1. Limited job.
sudo systemd-run --scope -p MemoryMax=100M stress-ng --vm 1 --vm-bytes 300M --timeout 20s

Output:

Running scope ... killed
  1. Check events.
journalctl -k | grep -i 'memory cgroup out of memory' | tail -1

Output:

Memory cgroup out of memory: Killed process
  1. Service limit.
sudo systemctl set-property sshd.service TasksMax=200 && systemctl show sshd -p TasksMax

Output:

TasksMax=200

Ravindra Bagale's Tip

To debug inside a container that has no tools, do not install anything in it. Find its host PID with docker inspect, then run host tools inside its namespaces with nsenter -t PID -n (network) or -m (mount). You keep the image clean and still see everything.

18. Frequently asked questions

Q. What is a kernel module?

A driver or feature loaded into the running kernel.

Q. Is /proc on disk?

No, it is generated live by the kernel.

Q. modprobe vs insmod?

modprobe handles dependencies; prefer it.

Q. Are containers VMs?

No, processes with namespaces and cgroups on the same kernel.

Q. cgroup v1 or v2?

v2 on modern distros; one unified tree.

Q. Exit code 137?

Killed by SIGKILL, often OOM.

Q. Change kernel live?

Tunables via sysctl; new kernel needs reboot.

Q. What is nsenter for?

Running a command inside another process's namespaces.

19. Interview questions and answers

Beginner level

Q. Show kernel version?

uname -r.

Q. List loaded modules?

lsmod.

Q. What is /proc?

Virtual filesystem with live kernel and process data.

Q. Load a module?

modprobe NAME.

Mid level level

Q. Load a module at boot?

/etc/modules-load.d/NAME.conf.

Q. Limit memory of a service?

systemctl set-property UNIT MemoryMax=.

Q. List namespaces?

lsns.

Q. Disk full, du small?

Deleted open files; lsof +L1.

Senior level

Q. How do containers isolate?

Namespaces for view, cgroups for resources, plus seccomp and capabilities.

Q. Debug a distroless pod's network?

Find PID, nsenter -t PID -n with host tools.

Q. cpu.max 50000 100000 means?

50 ms per 100 ms = half a CPU.

Q. Why Kubernetes needs br_netfilter?

So bridged pod traffic passes through iptables rules.

Try at home

  1. Run lsns and cat /proc/self/cgroup on your machine and explain each line.
  2. Run a backup with systemd-run and a 300M memory limit.

Practise this chapter

Interview questions and answers

How do namespaces and cgroups contribute differently to a container?

A namespace changes the process’s view, such as the network interfaces and routes it sees. A cgroup groups its processes for resource measurements and limits. They operate under the host’s kernel. Compare an inside/outside view and an assigned limit as separate tests.

Check your understanding

Choose an answer, then compare your reasoning with the explanation.

0 of 3 answered correctly
1. What does /proc/PID describe?

Answer and explanation

B. A live view of the process identified by that PID

The kernel exposes current process information through /proc. The numbered entry normally goes away when that process exits.

2. Which Linux feature gives processes their own view of network interfaces?

Answer and explanation

B. A network namespace

Network namespaces isolate network views and resources. Cgroups control and account for resources.

3. The host has free RAM but this job reaches memory.max. What condition matters?

Answer and explanation

B. The job’s cgroup has its own enforced memory cap

Cgroup limits can constrain processes in that group even while other RAM remains available to the host.

Practice Tasks

Practice checks run in your browser. They check the answer for this exercise; they do not create resources or connect to your AWS account.

About this scenario

London Legal LLP is a law business in London. Oliver Hughes looks after its IT and cloud work. They count money in GBP and run their AWS resources in the eu-west-2 Region. In the tasks below you do real jobs for them using what this lesson teaches. All names, account IDs, IP addresses and numbers are made up for practice.

0 / 18

Easy All kernel info

Containers at BIZ are kernel features.

Print the kernel name and machine hardware name.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy Module info

Containers at BIZ are kernel features.

Show information about module xfs.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy Is nvme loaded?

Containers at BIZ are kernel features.

Check if any module named like nvme_core is loaded.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy meminfo

Containers at BIZ are kernel features.

Show the first lines of /proc/meminfo with head (5 lines).

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy PID namespaces

Containers at BIZ are kernel features.

List only pid namespaces.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy List netns

Containers at BIZ are kernel features.

List network namespaces.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy cgroup version

Containers at BIZ are kernel features.

Print the filesystem type of /sys/fs/cgroup.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy cgroup tree

Containers at BIZ are kernel features.

Show the systemd cgroup tree for system.slice.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Load wireguard

Containers at BIZ are kernel features.

Load module wireguard.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Unload a module

Containers at BIZ are kernel features.

Unload module pcspkr.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Kernel errors

Containers at BIZ are kernel features.

Show only critical and error kernel messages with readable time.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Previous boot kernel

Containers at BIZ are kernel features.

Show kernel messages from two boots ago.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Process status

Containers at BIZ are kernel features.

Show /proc status of PID 1.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium New hostname world

Containers at BIZ are kernel features.

Start bash in a new IPC namespace (fork).

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Create netns

Containers at BIZ are kernel features.

Create a network namespace called blue.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Limit tasks

Containers at BIZ are kernel features.

Limit nginx.service to 300 tasks live.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Hard Enter mount ns

Containers at BIZ are kernel features.

Enter the mount namespace of PID 9100 and run df -h.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Hard Limited one-off

Containers at BIZ are kernel features.

Run gzip -9 big.log in a scope with MemoryMax=200M.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

In short

  1. uname -r and /proc/cmdline show kernel and boot options.
  2. lsmod, modinfo, modprobe manage drivers; modprobe.d for options and blacklists.
  3. /proc and /sys are live kernel files.
  4. Namespaces limit what a process sees.
  5. cgroups limit what it uses; systemd sets them easily.
  6. A container = process + namespaces + cgroups.

Revision, comparison and interview cards

Revise this lesson in a few minutes. Save the cards on your phone or download them as PNG files. The QR code on each card opens this lesson.

Kernel modules. Drivers loaded at runtime. lsmod lists, modinfo explains. modprobe loads with deps. Load one.
Revision card: Kernel modules · Download PNG · Open card page
cgroups in 4 steps. Limit CPU and memory. Containers use them. systemd sets them per unit. Live view.
Revision card: cgroups in 4 steps · Download PNG · Open card page
namespaces vs cgroups. What a process can see. / How much it can use.
Comparison: namespaces vs cgroups · Download PNG · Open card page
modprobe vs insmod. Loads by name with dependencies. / Loads one .ko file only.
Comparison: modprobe vs insmod · Download PNG · Open card page
What is /proc?. Virtual files from the kernel. Live process and system info. Process limits.
Interview card: What is /proc? · Download PNG · Open card page
How do containers isolate?. Namespaces: pid, net, mnt, uts. cgroups limit resources. List.
Interview card: How do containers isolate? · Download PNG · Open card page
Process killed suddenly?. OOM killer, memory limit hit. Check kernel log. Find.
Interview card: Process killed suddenly? · Download PNG · Open card page
cgroup v1 vs v2?. v2 has one unified tree. Modern distros use v2. Check.
Interview card: cgroup v1 vs v2? · Download PNG · Open card page

More cards: Ravi Sir's Cards.