Enter the namespaces of another process.
high risk
nsenter -t <pid> -n ss -tnpEnter only the network namespace (-n) for read-only diagnostics.nsenter runs a program in the namespace(s) of an existing process. Essential for debugging containerized processes — enter a container's network namespace to run network tools that aren't available inside the container, or debug a pod's network stack using host tools.
| Flag | Meaning |
|---|---|
-t --target | Target process PID |
-n --net | Enter network namespace |
-p --pid | Enter PID namespace |
-m --mount | Enter mount namespace |
--all | Enter all namespaces |
nsenter -t $(docker inspect -f '{{.State.Pid}}' mycontainer) -n ss -tnpRun ss inside a container's network namespace · explain & risk-check →nsenter -t 1234 --net ip addrShow network interfaces from another process's view · explain & risk-check →nsenter -t $(pgrep nginx | head -1) --all bashFull shell inside nginx's namespace · explain & risk-check →Use nsenter to debug distroless or scratch containers that have no shell — run `nsenter -t <container-pid> -n tcpdump` from the host to capture traffic inside a container with no tools.
Reference text is hand-written and may be incomplete — check man nsenter for your version. Test destructive commands on a non-production system first.