info > namespaces(7)

📋 NAME

namespaces — overview of Linux namespaces

🚀 Quick Reference

Use CaseCommandDescription
🔍 List current process namespacesls -l /proc/$$/nsShow symlinks to all namespace handles
🆕 Create new namespace (e.g., network)unshare -nRun command in a new network namespace
🔄 Join existing namespacensenter --target PID --netEnter the network namespace of a process
🔗 Bind mount namespace to keep alivemount --bind /proc/PID/ns/net /some/pathPrevent namespace destruction when no process remains
📊 Show namespace inodereadlink /proc/$$/ns/utsDisplay namespace type and inode number
🔒 Check namespace limitscat /proc/sys/user/max_*_namespacesView per-user namespace creation limits
📋 List all namespaces on systemlsnsList all namespaces of a given type (see lsns(8))

📝 DESCRIPTION

A namespace wraps a global system resource in an abstraction that makes it appear to the processes within the namespace that they have their own isolated instance of the global resource. Changes to the global resource are visible to other processes that are members of the namespace, but are invisible to other processes. One use of namespaces is to implement containers.

This page provides pointers to information on the various namespace types, describes the associated /proc files, and summarizes the APIs for working with namespaces.

📦 Namespace types

The following table shows the namespace types available on Linux. The second column shows the flag value used to specify the namespace type in various APIs. The third column identifies the manual page with details. The last column is a summary of the isolated resources.

🚀 NamespaceFlag📄 PageIsolates
📦 CgroupCLONE_NEWCGROUPcgroup_namespaces(7)Cgroup root directory
🔗 IPCCLONE_NEWIPCipc_namespaces(7)System V IPC, POSIX message queues
🌐 NetworkCLONE_NEWNETnetwork_namespaces(7)Network devices, stacks, ports, etc.
📁 MountCLONE_NEWNSmount_namespaces(7)Mount points
🆔 PIDCLONE_NEWPIDpid_namespaces(7)Process IDs
⏱️ TimeCLONE_NEWTIMEtime_namespaces(7)Boot and monotonic clocks
👤 UserCLONE_NEWUSERuser_namespaces(7)User and group IDs
🖥️ UTSCLONE_NEWUTSuts_namespaces(7)Hostname and NIS domain name

🔧 The namespaces API

As well as various /proc files described below, the namespaces API includes the following system calls:

Creation of new namespaces using clone(2) and unshare(2) in most cases requires the CAP_SYS_ADMIN capability, since in the new namespace, the creator will have the power to change global resources that are visible to other processes. User namespaces are the exception: since Linux 3.8, no privilege is required to create a user namespace.

📁 The /proc/[pid]/ns/ directory

Each process has a /proc/[pid]/ns/ subdirectory containing one entry for each namespace that supports being manipulated by setns(2):

$ ls -l /proc/$$/ns | awk '{print $1, $9, $10, $11}'
total 0
lrwxrwxrwx. cgroup -> cgroup:[4026531835]
lrwxrwxrwx. ipc -> ipc:[4026531839]
lrwxrwxrwx. mnt -> mnt:[4026531840]
lrwxrwxrwx. net -> net:[4026531969]
lrwxrwxrwx. pid -> pid:[4026531836]
lrwxrwxrwx. pid_for_children -> pid:[4026531834]
lrwxrwxrwx. time -> time:[4026531834]
lrwxrwxrwx. time_for_children -> time:[4026531834]
lrwxrwxrwx. user -> user:[4026531837]
lrwxrwxrwx. uts -> uts:[4026531838]

Bind mounting (see mount(2)) one of the files in this directory to somewhere else in the filesystem keeps the corresponding namespace of the process specified by pid alive even if all processes currently in the namespace terminate.

Opening one of the files in this directory (or a file that is bind mounted to one of these files) returns a file handle for the corresponding namespace of the process specified by pid. As long as this file descriptor remains open, the namespace will remain alive, even if all processes in the namespace terminate. The file descriptor can be passed to setns(2).

In Linux 3.7 and earlier, these files were visible as hard links. Since Linux 3.8, they appear as symbolic links. If two processes are in the same namespace, then the device IDs and inode numbers of their /proc/[pid]/ns/xxx symbolic links will be the same; an application can check this using the stat.st_dev and stat.st_ino fields returned by stat(2). The content of this symbolic link is a string containing the namespace type and inode number as in the following example:

$ readlink /proc/$$/ns/uts
uts:[4026531838]

The symbolic links in this subdirectory are as follows:

Permission to dereference or read (readlink(2)) these symbolic links is governed by a ptrace access mode PTRACE_MODE_READ_FSCREDS check; see ptrace(2).

⚙️ The /proc/sys/user directory

The files in the /proc/sys/user directory (present since Linux 4.9) expose limits on the number of namespaces of various types that can be created. The files are as follows:

Note the following details about these files:

⏳ Namespace lifetime

Absent any other factors, a namespace is automatically torn down when the last process in the namespace terminates or leaves the namespace. However, there are a number of other factors that may pin a namespace into existence even though it has no member processes. These factors include the following:

💡 EXAMPLES

See clone(2) and user_namespaces(7).

📚 SEE ALSO

nsenter(1), readlink(1), unshare(1), clone(2), ioctl_ns(2), setns(2), unshare(2), proc(5), capabilities(7), cgroup_namespaces(7), cgroups(7), credentials(7), ipc_namespaces(7), network_namespaces(7), pid_namespaces(7), time_namespaces(7), user_namespaces(7), uts_namespaces(7), lsns(8), pam_namespace(8), switch_root(8)

📄 COLOPHON

This page is part of release 5.10 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/.

namespaces(7)
📋 NAME 🚀 Quick Reference 📝 DESCRIPTION
📦 Namespace types 🔧 The namespaces API 📁 The /proc/[pid]/ns/ directory ⚙️ The /proc/sys/user directory ⏳ Namespace lifetime
💡 EXAMPLES 📚 SEE ALSO 📄 COLOPHON

Generated by phpman v4.9.26-1-g511901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-08-04 07:19 @216.73.216.183
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format

^_top_^