concepts

Linux Namespaces — Isolated Resource Views

Namespaces give processes distinct views of selected system resources, including mount tables, PID numbers, network configuration, IPC resources, hostnames, user/group mappings, cgroup paths and selected clocks (time namespaces virtualize offsets for monotonic and boot-time clocks, not the real-time wall clock). They do not independently impose CPU or memory limits or form a complete security boundary. A process can share one namespace type with another while differing in another. The namespace links under /proc expose identifiers useful for comparing membership; an identifier is not a permanent security principal. User namespaces scope some capabilities to their owning namespace and mapped IDs. Do not create or join namespaces on a host simply to reproduce a lesson; use an explicitly authorized disposable VM for those changes. The example observes the caller and an ordinary child sharing the same mount namespace, without creation, reassociation or privilege changes. Example prerequisites: Linux, Bash and Python 3 standard library; run as a non-root user in a private temporary working directory. Example scope: native read-only observation. Expected output: ordinary child shares mount namespace. No system configuration changes.

Formal Syntax & Structure

linux syntaxlinux
/proc/self/ns/<type>; readlink /proc/self/ns/mnt

Parameters & Attributes

NameTypeDescription
typenamespace selectorExamples: mnt, pid, net, user, ipc, uts, cgroup, time.
namespace linkkernel identifierReadlink text for membership comparisons.
user mappingID mappingMaps user/group IDs between namespace levels.

Return Value

Concept / observation

The observed link is a namespace identity at observation time; example compares parent and child.

Working Example

Example Snippetlinux
python3 - <<'PY'import os,sys,subprocessparent=os.readlink('/proc/self/ns/mnt')child=subprocess.check_output([sys.executable,'-c',"import os; print(os.readlink('/proc/self/ns/mnt'))"],text=True,timeout=5).strip()assert parent.startswith('mnt:[') and parent.endswith(']')assert parent==childprint('ordinary child shares mount namespace')PY
Linux Reference