Linux namespaces
Quick answer
A namespace changes the view of a global resource for member processes. For example, a PID namespace changes visible process IDs while a mount namespace gives a separate mount-table view. Namespaces do not by themselves impose CPU or memory limits.
A process may see itself as PID 1 inside a PID namespace while the host sees a different PID. Identify the namespace from which an observation was made before comparing process lists. A separate namespace does not by itself prevent a workload from exhausting shared resources.
Prepare the practice environment
Run python3 lab-fixtures/containers-virtualization/setup.py from the extracted root as an ordinary user. Enter the printed private path and check pwd. Use fresh fixtures, Bash with set -e -o pipefail, LC_ALL=C and umask 077. The Python helper parses fictional examples or inspects its own child. No runtime daemon, external network or root access is needed. Do not apply the fictional JSON to any runtime. Version checks need the named tools.
Prerequisites
Review: Containers versus virtual machines.
How it works
PID namespaces provide hierarchical process-ID views; a process can have different IDs in ancestor and child views. The first process in a PID namespace has special init responsibilities. Mount namespaces isolate mount lists but propagation settings can share mount events. Network namespaces isolate network devices, routes and sockets. User namespaces map IDs and scope capabilities; UID 0 inside need not equal host UID 0. IPC namespaces isolate System V IPC and POSIX message queues; UTS namespaces isolate hostname and domain name; cgroup namespaces virtualize cgroup paths; time namespaces virtualize selected monotonic and boot-time clocks. The symbolic links in /proc/PID/ns identify namespace instances; compare the same type for two authorized processes. lsns lists accessible namespaces and can miss instances due to procfs visibility or permissions. The examples inspect only the current process or its child and never enter or create namespaces.
Try the examples
lsns -p "$$" -n -o TYPE | sort -u | grep -xE 'mnt|net|pid|user'The local view exposes these four types; IDs and available types vary.
Expected stdout:
mntnetpiduserA real child inherits the mount namespace when no namespace-changing operation is requested.
Expected stdout:
child shares parent mount namespaceFictional IDs illustrate two views of one process; no PID namespace is created.
Expected stdout:
host view: 4200; child view: 1Common mistakes
A mount namespace is not automatically a private filesystem, and a network namespace is not automatically disconnected. Do not run nsenter on arbitrary host processes or weaken namespace restrictions to complete a lab.
Practice
Inspect your own namespace links and compare them with an ordinary child. Identify which namespace type would change for a separate hostname, mount view or network stack.
Related references
Study: lsns. These are reference names, not deployed links.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Linux namespaces — Knowledge Check
Apply container and virtualization concepts to concrete local examples.
Which namespace changes process ID visibility?
What can UID 0 in a user namespace represent?
Which feature controls CPU bandwidth rather than visibility?
What does matching mount namespace identity show?