Linux Namespaces Explained: The Eight Types and What They Isolate
Linux has eight namespace types: mount, PID, network, IPC, UTS, user, cgroup and time. Each one gives a process its own view of one kind of kernel resource.

A container is not a kernel feature. It is a process that the kernel has been told to show a smaller world. The tool for that is the namespace: a wrapper around one global resource that makes the resource appear to be private to the processes inside it. Linux 6.12 has eight kinds, and a container runtime combines several of them. This post names each one, says exactly what it isolates and what it leaves shared, and shows how to see your own namespaces from a shell. You need no root access and no special tools beyond ls and readlink to follow it.
What a namespace does
Every process belongs to exactly one namespace of each type. Initially all processes on the machine share the same set, the root namespaces. When a process creates a new namespace, with clone(2), unshare(2) or setns(2), it and its future children see a different instance of that one resource. Other processes still see the old instance.
Namespaces are the visibility half of containers. They decide what a process can see: which mounts, which process IDs, which network interfaces. They do not decide how much it can use. Limits on memory and CPU belong to cgroups, a separate mechanism covered in the next posts of this series. A namespace also does not make a process harmless: a root process with the right capabilities can often reach outside it. Treat namespaces as one layer of isolation, not a sandbox on their own.
The eight types
The namespaces(7) man page lists them, and each has a clone flag and a version in which it first appeared in Linux.
| Namespace | Clone flag | What it isolates | Since |
|---|---|---|---|
| Mount | CLONE_NEWNS | The list of mount points | 2.4.19 |
| UTS | CLONE_NEWUTS | Hostname and NIS domain name | 2.6.19 |
| IPC | CLONE_NEWIPC | System V IPC and POSIX message queues | 2.6.19 |
| PID | CLONE_NEWPID | Process IDs | 2.6.24 |
| Network | CLONE_NEWNET | Interfaces, routes, firewall rules, ports | 2.6.29 |
| User | CLONE_NEWUSER | User and group IDs, capabilities | 3.8 |
| Cgroup | CLONE_NEWCGROUP | The view of the cgroup hierarchy | 4.6 |
| Time | CLONE_NEWTIME | Boot-time and monotonic clock offsets | 5.6 |
The mount flag is named NEWNS for historical reasons: it was the first namespace and nobody thought there would be more.
Mount
A mount namespace gives a process its own tree of mount points. Mounting or unmounting inside it does not change what other processes see, subject to propagation rules that decide whether mounts are shared or private. This is what lets a container have its own root filesystem. It is also the namespace with the most surprising defaults, because on systems using systemd the root mount is shared, so mounts made in a new namespace can leak back unless you mark them private.
UTS
The UTS namespace holds the hostname and domain name. A container can call sethostname without renaming the host. It is the smallest namespace and the easiest one to experiment with.
IPC
System V shared memory, semaphores and message queues, and POSIX message queues, are global by default. An IPC namespace gives a process its own set, so two containers using the same key do not collide or read each other's segments.
PID
A PID namespace gives a process its own numbering. The first process in a new one is PID 1 inside it, and it sees only processes in its namespace and below. A process has one PID per namespace level, which is why the same process can be PID 1 in a container and PID 18234 on the host. PID 1 inside also gets special signal handling: it ignores signals it has not installed handlers for, and if it exits the kernel kills every other process in that namespace.
Network
A network namespace has its own interfaces, IP addresses, routing tables, firewall rules and port numbers. A new one starts with only a loopback device that is down. Two containers can each listen on port 80 because they are in different network namespaces. Virtual ethernet pairs connect a namespace to another one.
User
The user namespace maps user and group IDs. A process can be UID 0 inside its namespace and an ordinary UID outside, and capabilities it holds inside apply only to resources owned by that namespace. This is what makes unprivileged, rootless containers possible. It is also the namespace most tied to security history, because it lets unprivileged users reach kernel code that used to need root.
Cgroup
A cgroup namespace virtualises the view of /proc/PID/cgroup and the cgroup hierarchy, so a container sees its own cgroup as the root. It does not enforce limits. It hides the host's layout from the container.
Time
A time namespace lets a process see different offsets for CLOCK_MONOTONIC and CLOCK_BOOTTIME. It does not change CLOCK_REALTIME, the wall clock. Its main use is to keep the monotonic clock continuous when a container is restored on another host, a topic from checkpoint and restore in a later post.
See your own namespaces
Every process exposes its namespaces as symbolic links under /proc/PID/ns. You can read them without privileges for your own processes.
ls -l /proc/self/nstotal 0
lrwxrwxrwx 1 user user 0 Nov 23 10:00 cgroup -> 'cgroup:[4026531835]'
lrwxrwxrwx 1 user user 0 Nov 23 10:00 ipc -> 'ipc:[4026531839]'
lrwxrwxrwx 1 user user 0 Nov 23 10:00 mnt -> 'mnt:[4026531841]'
lrwxrwxrwx 1 user user 0 Nov 23 10:00 net -> 'net:[4026531840]'
lrwxrwxrwx 1 user user 0 Nov 23 10:00 pid -> 'pid:[4026531836]'
lrwxrwxrwx 1 user user 0 Nov 23 10:00 pid_for_children -> 'pid:[4026531836]'
lrwxrwxrwx 1 user user 0 Nov 23 10:00 time -> 'time:[4026531834]'
lrwxrwxrwx 1 user user 0 Nov 23 10:00 time_for_children -> 'time:[4026531834]'
lrwxrwxrwx 1 user user 0 Nov 23 10:00 user -> 'user:[4026531837]'
lrwxrwxrwx 1 user user 0 Nov 23 10:00 uts -> 'uts:[4026531838]'The number in brackets is the inode of the namespace. Two processes are in the same namespace exactly when those numbers match. The dates and exact inode numbers on your machine will differ, but the shape will not. The pid_for_children and time_for_children entries exist because creating one of those namespaces does not move the calling process: it moves only the children it forks afterwards.
To compare a container to the host, run the same command inside it and diff the inodes. A container with its own network and PID namespace shows different values for net and pid and the same value for user, unless it is rootless.
What namespaces leave shared
A namespace isolates one resource. The kernel itself, its modules, dmesg, the system clock, most of /sys and the CPU and memory are shared by every container on the host. That is the difference between a container and a virtual machine: a kernel bug reachable from a container is a bug in the host's kernel. This is the reason sandboxes combine namespaces with seccomp filters, dropped capabilities and read-only paths, and the reason lightweight virtual machines exist for stronger separation.
How a runtime combines them
A typical container gets a new mount, UTS, IPC, PID and network namespace. A rootless one adds a user namespace first, because creating the others without privilege needs the capabilities a user namespace grants. A cgroup namespace appears in most modern setups. The time namespace is rarely used outside checkpoint and restore. Joining an existing namespace, as docker exec and nsenter do, uses setns(2) on the file descriptors from /proc/PID/ns.


