Articles
Linux Namespace Interview Questions: Processes, Mounts, and Network Isolation
Practice Linux namespace interview questions with PID numbering, mount views, network stacks, namespace handles, and practical security boundaries.
Two processes run on the same Linux host. One sees PID 1 as its application, another sees a different filesystem tree, and neither sees the other's network interface. Are they in “a container”? The interview-worthy answer is more precise: PID, mount, and network namespaces are separate views, and none of them alone establishes a complete security boundary.
This guide uses the Linux namespaces(7), pid_namespaces(7), mount_namespaces(7), and network_namespaces(7) manuals for kernel behavior. The exercises are original scenarios, not candidate reports or a company's question bank. For the separate resource-control boundary, see the Linux cgroups guide.
Question 1: What does a namespace isolate?
Linux namespaces make selected global system resources appear different to processes in different namespace instances. The namespace type matters. A PID namespace changes process-ID visibility and numbering; a mount namespace changes the set and arrangement of mounts visible to a process; a network namespace supplies a separate network stack view with its own interfaces, routes, and port space. A process has an association for each namespace type, so saying “it is in a namespace” hides the facts needed to debug it.
The mechanism is a view, not a complete container implementation. A typical container also relies on filesystem setup, cgroups for resource control, capabilities and user identity rules, and often seccomp or other security policies. Namespaces can reduce what a process can see or reach, but they do not automatically prevent every action the process is privileged to perform. In an interview, state both what is isolated and what policy still needs verification.
The /proc/<pid>/ns/ entries expose namespace handles as symbolic links. Comparing their identifiers for two processes can show whether they share a given namespace instance, subject to access controls and a trustworthy host view of /proc. Do not infer all isolation from a container name or image tag. Inspect each type that is relevant to the incident.
Question 2: Why is PID 1 inside not PID 1 on the host?
A process can have different PIDs in nested PID namespaces. Inside a child PID namespace, the first process is PID 1 for that namespace. From an ancestor PID namespace, such as the host's, that same process has a different PID. Processes in a child PID namespace cannot see processes that exist only in an ancestor; the ancestor can see processes in the child under ancestor-visible numbers. The precise view depends on where the observer runs.
This matters operationally. A diagnostic command run inside the container may see only its own process tree; a host command sees more. If an alert quotes host PID 4582 and a container log quotes PID 1, those can be the same task. Match process identity through host runtime metadata or namespace-aware inspection, rather than assuming one log is wrong.
PID 1 in a PID namespace also has special lifecycle implications. If its namespace init process exits, the namespace's other processes are terminated. Signals and reaping of orphaned children are part of why a container's entrypoint design matters. But a PID namespace by itself does not decide who can send signals across namespace boundaries; permissions, credentials, and the observer's namespace matter. Avoid the blanket claim “the host cannot signal container processes.”
Question 3: What does a mount namespace change?
A mount namespace isolates a process's view of mount points. Two processes can have different filesystem trees even when they run on the same kernel. This is why an application may see a bind mount or a /proc mount that differs from the host's. It does not mean it has a separate physical disk: mounts may point to shared underlying filesystems or devices.
Ask which path and which namespace the path was observed from. A file at /data/report inside a container can correspond to a host path or volume with a different name. If an incident claims a file is “missing,” check the mount tree, bind mounts, propagation settings, and container runtime configuration before deciding it was deleted. A change in one mount namespace need not appear identically in another; mount propagation can alter what changes cross boundaries.
Also separate mount visibility from file permissions. A process may see a mounted filesystem but still lack permission to read a path. Conversely, an overly broad bind mount can expose sensitive host data despite the separate mount tree. The right security question is which paths were mounted, with what permissions and privileges, not whether a mount namespace exists.
/proc needs care in PID-namespace exercises. A process can live in a child PID namespace but see a /proc mount that does not reflect the intended process view if the filesystem setup is wrong. When an example says “ps sees host processes,” do not instantly conclude PID namespaces failed. Inspect how /proc is mounted in that mount namespace and compare the namespace handles and host-side process listing.
Question 4: What belongs to a network namespace?
A network namespace provides its own network devices, IP addresses, routing tables, firewall rules, and port-number space. A process listening on port 8080 in one network namespace does not by itself occupy port 8080 in another. A common container setup uses a virtual Ethernet pair and routes or bridges to connect a container namespace to the host or other networks. The exact topology is runtime-specific, so draw it for the given scenario instead of assuming every container uses the same bridge.
If a service works from inside its container but not from the host, locate the listening socket in the correct network namespace. Check the interface/address it binds, the namespace route table, the veth path, and any port mapping or host firewall. Binding only to loopback inside the container means loopback in that namespace; it is not the host's loopback address. That is a frequent debugging trap.
Namespace isolation is not necessarily a disconnection policy. A network namespace may have interfaces and routes that provide full external access. It may share the host network namespace if configured that way. Security depends on connectivity, firewalling, capabilities, and runtime choices. “Separate network namespace” is a structural fact, not proof that two services cannot communicate.
A three-view diagnosis table
This original decision aid forces the observer's location into the answer. It works best when the interviewer gives a host PID, container PID, path, and connection failure.
| Symptom | First namespace question | Distinguishing evidence |
|---|---|---|
Host shows a process, container ps does not | Which PID namespace is each observer in? | Compare /proc/<pid>/ns/pid and host/container PID mapping |
Container sees /data, host does not see that path | Which mount namespace and bind mount define /data? | Inspect mount tables from both views and runtime volume configuration |
localhost:8080 works inside only | Which network namespace owns the listening socket? | Compare listeners, bound address, interfaces, and published-port path |
| Container hits memory limit with host RAM free | Is this a namespace issue at all? | Read its cgroup memory limit and events, not just namespace handles |
Host ps inside a tool container looks surprising | Which /proc is mounted there? | Check PID namespace and /proc mount together |
The fourth row deliberately tests a category error. Cgroups, rather than namespaces, govern resource accounting and limits. The same process can have a private PID view while sharing CPU or memory capacity under a cgroup hierarchy. Our Linux cgroups interview guide explores that separate mechanism.
Question 5: How would you inspect a live process safely?
Start from a known host PID and compare the relevant /proc/<pid>/ns/ links with those of the suspected peer and the host. Read the process's mount information and, where permitted, network namespace state. The lsns and nsenter tools can assist, but their output depends on privileges and the namespace from which they run. Joining a namespace with nsenter changes the context of the diagnostic command; treat that as an intentional operator action and avoid altering the workload while merely collecting evidence.
Record both the namespace identifier and the observer location with every observation. “Port 8080 is open” is incomplete without the network namespace and bound address. “PID 1 is healthy” is incomplete without saying which PID namespace. “The file exists” is incomplete without the mount namespace and path mapping. This discipline makes apparently contradictory logs compatible.
For a reproduction, create a disposable test environment using the runtime your team actually operates, then compare host and container views of process IDs, mounts, and listeners. Do not needlessly grant broad capabilities to make the experiment work. If a tool cannot inspect a namespace due to access controls, state that limitation and collect the same evidence through the host's supported runtime interface. An interview answer should not imply that every command works from an unprivileged container shell.
Question 6: Is a namespace a security boundary?
It is one isolation mechanism, and its usefulness depends on the rest of the security configuration. User namespaces can map identities and affect privilege interpretation; capabilities define privileges; seccomp can limit syscalls; mount configuration controls exposed paths; network policy controls reachability; cgroups constrain resource use. The official user_namespaces(7) manual helps explain why “root inside” and “root on the host” are not interchangeable in configurations that use user namespaces.
The interview should avoid two extremes. It is wrong to say namespaces provide no isolation: they clearly provide distinct resource views. It is also wrong to say they make a container secure by themselves. A process can share a network namespace, receive a dangerous host mount, or run with permissions that defeat an intended boundary. Ask for the concrete threat and configuration before making a security claim.
If the problem is a compromised application, identify the assets it can reach: host files exposed through mounts, network destinations and services, credentials, kernel capabilities, and runtime APIs. That assessment is more useful than listing namespace names. A namespace diagram should lead to an actionable permission or connectivity check.
A concise interview answer
“I would name the namespace type and the observer. A PID namespace changes process numbering and visibility; the host may see a child-namespace process under a different PID. A mount namespace changes the mount tree, so a container path may map to a host volume. A network namespace has its own interfaces, routes, and port space, so localhost inside it is not host loopback. I would compare /proc/<pid>/ns handles, mount tables, and network listeners from the right context. Then I would separately check cgroups and security controls before claiming resource or security isolation.”
| Practice question | Connection to this scenario |
|---|---|
| Explain Linux Command Execution, Filesystems, and Isolation | Describe process and filesystem views. |
| Explain OS processes, threads, and memory | Distinguish process identity from resource accounting. |
| Diagnose Slow Network Throughput Including Containers | Trace network paths across namespaces. |
| Design a sandboxed cloud IDE | Choose isolation controls for a concrete threat. |
| Design secure Kubernetes with CI/CD | Connect container boundaries to deployment security. |
Continue with Linux cgroups interview questions and draw a single process with its PID, mount, and network namespace memberships on separate lines. Add its cgroup as a fourth line. If those four lines collapse into one “container” box, the diagnostic model is still too vague.
Sources and further reading
- Linux manual: namespaces(7) — namespace types and per-process associations.
- Linux manual: pid_namespaces(7) — process-ID visibility and namespace init behavior.
- Linux manual: mount_namespaces(7) — mount views and propagation.
- Linux manual: network_namespaces(7) — interfaces, routing, and network stack separation.
- Linux manual: user_namespaces(7) — user and group ID mappings.