openskills.info
Course Preview

Linux Namespaces and Control Groups

Linux namespaces give a process a restricted view of selected system resources. Control groups organize processes into a hierarchy that accounts for and controls their use of CPU, memory, I/O, and other resources.

itLinux

Linux Namespaces and Control Groups

Linux namespaces and control groups, usually called cgroups, are kernel mechanisms for managing processes. A namespace changes what a process can see. A cgroup changes how much of a resource a process group can use and records what it has used. Container runtimes combine both mechanisms with capabilities, filesystem setup, and syscall filtering, but namespaces and cgroups are useful outside containers too.

These mechanisms do not create a second kernel. Namespaced processes still issue system calls to the host kernel. That shared-kernel boundary gives containers low overhead, but it also means a namespace boundary is not equivalent to a virtual-machine boundary.

Two independent dimensions

A process belongs to one namespace of each supported type. Each type isolates a particular view:

  • A mount namespace supplies a mount table, so a process can see a different filesystem layout.
  • A PID namespace supplies a process-ID view. The first process in a new PID namespace has PID 1 there and has special responsibilities for child processes.
  • A network namespace supplies network devices, protocol stacks, routing tables, firewall rules, and port-number space.
  • A user namespace maps user and group IDs between the namespace and its parent. A process can hold capabilities inside that namespace without holding the same capabilities in the initial user namespace.
  • UTS, IPC, cgroup, and time namespaces isolate host and domain names, IPC objects, cgroup-root views, and selected clocks.

Cgroups answer a different question. The cgroup v2 hierarchy places processes in a tree. Controllers expose files that account for or control resources such as CPU, memory, I/O, and process count. A process can share every namespace with another process while belonging to a different cgroup, or share a cgroup while using different namespaces.

This separation is the central mental model: namespaces partition views; cgroups organize and govern resource use.

Continue the course

This section is part of the paid course.

See pricing to subscribe, or log in if you already have access.

Where this skill leads

Relevant careers

See how this topic contributes to broader role-level skill maps.

Sources