1NSENTER(1) User Commands NSENTER(1)
2
3
4
6 nsenter - run program with namespaces of other processes
7
9 nsenter [options] [program [arguments]]
10
12 Enters the namespaces of one or more other processes and then executes
13 the specified program. Enterable namespaces are:
14
15 mount namespace
16 Mounting and unmounting filesystems will not affect the rest of
17 the system (CLONE_NEWNS flag), except for filesystems which are
18 explicitly marked as shared (with mount --make-shared; see /proc
19 /self/mountinfo for the shared flag).
20
21 UTS namespace
22 Setting hostname or domainname will not affect the rest of the
23 system. (CLONE_NEWUTS flag)
24
25 IPC namespace
26 The process will have an independent namespace for System V mes‐
27 sage queues, semaphore sets and shared memory segments. (CLONE_
28 NEWIPC flag)
29
30 network namespace
31 The process will have independent IPv4 and IPv6 stacks, IP rout‐
32 ing tables, firewall rules, the /proc/net and /sys/class/net
33 directory trees, sockets, etc. (CLONE_NEWNET flag)
34
35 PID namespace
36 Children will have a set of PID to process mappings separate
37 from the nsenter process (CLONE_NEWPID flag). nsenter will fork
38 by default if changing the PID namespace, so that the new pro‐
39 gram and its children share the same PID namespace and are visi‐
40 ble to each other. If --no-fork is used, the new program will
41 be exec'ed without forking.
42
43 user namespace
44 The process will have a distinct set of UIDs, GIDs and capabili‐
45 ties. (CLONE_NEWUSER flag)
46
47 See clone(2) for the exact semantics of the flags.
48
49 If program is not given, then ``${SHELL}'' is run (default: /bin/sh).
50
51
53 -t, --target pid
54 Specify a target process to get contexts from. The paths to the
55 contexts specified by pid are:
56
57 /proc/pid/ns/mnt the mount namespace
58 /proc/pid/ns/uts the UTS namespace
59 /proc/pid/ns/ipc the IPC namespace
60 /proc/pid/ns/net the network namespace
61 /proc/pid/ns/pid the PID namespace
62 /proc/pid/ns/user the user namespace
63 /proc/pid/root the root directory
64 /proc/pid/cwd the working directory respectively
65
66 -m, --mount[=file]
67 Enter the mount namespace. If no file is specified, enter the
68 mount namespace of the target process. If file is specified,
69 enter the mount namespace specified by file.
70
71 -u, --uts[=file]
72 Enter the UTS namespace. If no file is specified, enter the UTS
73 namespace of the target process. If file is specified, enter
74 the UTS namespace specified by file.
75
76 -i, --ipc[=file]
77 Enter the IPC namespace. If no file is specified, enter the IPC
78 namespace of the target process. If file is specified, enter
79 the IPC namespace specified by file.
80
81 -n, --net[=file]
82 Enter the network namespace. If no file is specified, enter the
83 network namespace of the target process. If file is specified,
84 enter the network namespace specified by file.
85
86 -p, --pid[=file]
87 Enter the PID namespace. If no file is specified, enter the PID
88 namespace of the target process. If file is specified, enter
89 the PID namespace specified by file.
90
91 -U, --user[=file]
92 Enter the user namespace. If no file is specified, enter the
93 user namespace of the target process. If file is specified,
94 enter the user namespace specified by file. See also the
95 --setuid and --setgid options.
96
97 -G, --setgid gid
98 Set the group ID which will be used in the entered namespace and
99 drop supplementary groups. nsenter(1) always sets GID for user
100 namespaces, the default is 0.
101
102 -S, --setuid uid
103 Set the user ID which will be used in the entered namespace.
104 nsenter(1) always sets UID for user namespaces, the default is
105 0.
106
107 --preserve-credentials
108 Don't modify UID and GID when enter user namespace. The default
109 is to drops supplementary groups and sets GID and UID to 0.
110
111 -r, --root[=directory]
112 Set the root directory. If no directory is specified, set the
113 root directory to the root directory of the target process. If
114 directory is specified, set the root directory to the specified
115 directory.
116
117 -w, --wd[=directory]
118 Set the working directory. If no directory is specified, set
119 the working directory to the working directory of the target
120 process. If directory is specified, set the working directory
121 to the specified directory.
122
123 -F, --no-fork
124 Do not fork before exec'ing the specified program. By default,
125 when entering a PID namespace, nsenter calls fork before calling
126 exec so that any children will also be in the newly entered PID
127 namespace.
128
129 -Z, --follow-context
130 Set the SELinux security context used for executing a new
131 process according to already running process specified by --tar‐
132 get PID. (The util-linux has to be compiled with SELinux support
133 otherwise the option is unavailable.)
134
135 -V, --version
136 Display version information and exit.
137
138 -h, --help
139 Display help text and exit.
140
142 setns(2), clone(2)
143
145 Eric Biederman ⟨biederm@xmission.com⟩
146 Karel Zak ⟨kzak@redhat.com⟩
147
149 The nsenter command is part of the util-linux package and is available
150 from Linux Kernel Archive ⟨ftp://ftp.kernel.org/pub/linux/utils/util-
151 linux/⟩.
152
153
154
155util-linux June 2013 NSENTER(1)