]> git.ipfire.org Git - thirdparty/util-linux.git/blob - sys-utils/nsenter.1
Merge branch 'mbsencode' of https://github.com/yontalcar/util-linux
[thirdparty/util-linux.git] / sys-utils / nsenter.1
1 .TH NSENTER 1 "June 2013" "util-linux" "User Commands"
2 .SH NAME
3 nsenter \- run program with namespaces of other processes
4 .SH SYNOPSIS
5 .B nsenter
6 [options]
7 .RI [ program
8 .RI [ arguments ]]
9 .SH DESCRIPTION
10 Enters the namespaces of one or more other processes and then executes the specified
11 \fIprogram\fP. If \fIprogram\fP is not given, then ``${SHELL}'' is run (default: /bin\:/sh).
12 .PP
13 Enterable namespaces are:
14 .TP
15 .B mount namespace
16 Mounting and unmounting filesystems will not affect the rest of the system,
17 except for filesystems which are explicitly marked as shared (with
18 \fBmount --make-\:shared\fP; see \fI/proc\:/self\:/mountinfo\fP for the
19 \fBshared\fP flag).
20 For further details, see
21 .BR mount_namespaces (7)
22 and the discussion of the
23 .BR CLONE_NEWNS
24 flag in
25 .BR clone (2).
26 .TP
27 .B UTS namespace
28 Setting hostname or domainname will not affect the rest of the system.
29 For further details, see
30 .BR namespaces (7)
31 and the discussion of the
32 .BR CLONE_NEWUTS
33 flag in
34 .BR clone (2).
35 .TP
36 .B IPC namespace
37 The process will have an independent namespace for POSIX message queues
38 as well as System V message queues,
39 semaphore sets and shared memory segments.
40 For further details, see
41 .BR namespaces (7)
42 and the discussion of the
43 .BR CLONE_NEWIPC
44 flag in
45 .BR clone (2).
46 .TP
47 .B network namespace
48 The process will have independent IPv4 and IPv6 stacks, IP routing tables,
49 firewall rules, the
50 .I /proc\:/net
51 and
52 .I /sys\:/class\:/net
53 directory trees, sockets, etc.
54 For further details, see
55 .BR namespaces (7)
56 and the discussion of the
57 .BR CLONE_NEWNET
58 flag in
59 .BR clone (2).
60 .TP
61 .B PID namespace
62 Children will have a set of PID to process mappings separate from the
63 .B nsenter
64 process
65 For further details, see
66 .BR pid_namespaces (7)
67 and
68 the discussion of the
69 .BR CLONE_NEWPID
70 flag in
71 .B nsenter
72 will fork by default if changing the PID namespace, so that the new program
73 and its children share the same PID namespace and are visible to each other.
74 If \fB\-\-no\-fork\fP is used, the new program will be exec'ed without forking.
75 .TP
76 .B user namespace
77 The process will have a distinct set of UIDs, GIDs and capabilities.
78 For further details, see
79 .BR user_namespaces (7)
80 and the discussion of the
81 .BR CLONE_NEWUSER
82 flag in
83 .BR clone (2).
84 .TP
85 .B cgroup namespace
86 The process will have a virtualized view of \fI/proc\:/self\:/cgroup\fP, and new
87 cgroup mounts will be rooted at the namespace cgroup root.
88 For further details, see
89 .BR cgroup_namespaces (7)
90 and the discussion of the
91 .BR CLONE_NEWCGROUP
92 flag in
93 .BR clone (2).
94 .TP
95 See \fBclone\fP(2) for the exact semantics of the flags.
96 .SH OPTIONS
97 Various of the options below that relate to namespaces take an optional
98 .I file
99 argument.
100 This should be one of the
101 .IR /proc/[pid]/ns/*
102 files described in
103 .BR namespaces (7).
104 .TP
105 \fB\-a\fR, \fB\-\-all\fR
106 Enter all namespaces of the target process by the default
107 .IR /proc/[pid]/ns/*
108 namespace paths. The default paths to the target process namespaces may be
109 overwritten by namespace specific options (e.g. --all --mount=[path]).
110
111 The user namespace will be ignored if the same as the caller's current user
112 namespace. It prevents a caller that has dropped capabilities from regaining
113 those capabilities via a call to setns(). See
114 .BR setns (2)
115 for more details.
116 .TP
117 \fB\-t\fR, \fB\-\-target\fR \fIpid\fP
118 Specify a target process to get contexts from. The paths to the contexts
119 specified by
120 .I pid
121 are:
122 .RS
123 .PD 0
124 .IP "" 20
125 .TP
126 /proc/\fIpid\fR/ns/mnt
127 the mount namespace
128 .TP
129 /proc/\fIpid\fR/ns/uts
130 the UTS namespace
131 .TP
132 /proc/\fIpid\fR/ns/ipc
133 the IPC namespace
134 .TP
135 /proc/\fIpid\fR/ns/net
136 the network namespace
137 .TP
138 /proc/\fIpid\fR/ns/pid
139 the PID namespace
140 .TP
141 /proc/\fIpid\fR/ns/user
142 the user namespace
143 .TP
144 /proc/\fIpid\fR/ns/cgroup
145 the cgroup namespace
146 .TP
147 /proc/\fIpid\fR/root
148 the root directory
149 .TP
150 /proc/\fIpid\fR/cwd
151 the working directory respectively
152 .PD
153 .RE
154 .TP
155 \fB\-m\fR, \fB\-\-mount\fR[=\fIfile\fR]
156 Enter the mount namespace. If no file is specified, enter the mount namespace
157 of the target process.
158 If
159 .I file
160 is specified, enter the mount namespace
161 specified by
162 .IR file .
163 .TP
164 \fB\-u\fR, \fB\-\-uts\fR[=\fIfile\fR]
165 Enter the UTS namespace. If no file is specified, enter the UTS namespace of
166 the target process.
167 If
168 .I file
169 is specified, enter the UTS namespace specified by
170 .IR file .
171 .TP
172 \fB\-i\fR, \fB\-\-ipc\fR[=\fIfile\fR]
173 Enter the IPC namespace. If no file is specified, enter the IPC namespace of
174 the target process.
175 If
176 .I file
177 is specified, enter the IPC namespace specified by
178 .IR file .
179 .TP
180 \fB\-n\fR, \fB\-\-net\fR[=\fIfile\fR]
181 Enter the network namespace. If no file is specified, enter the network
182 namespace of the target process.
183 If
184 .I file
185 is specified, enter the network namespace specified by
186 .IR file .
187 .TP
188 \fB\-p\fR, \fB\-\-pid\fR[=\fIfile\fR]
189 Enter the PID namespace. If no file is specified, enter the PID namespace of
190 the target process.
191 If
192 .I file
193 is specified, enter the PID namespace specified by
194 .IR file .
195 .TP
196 \fB\-U\fR, \fB\-\-user\fR[=\fIfile\fR]
197 Enter the user namespace. If no file is specified, enter the user namespace of
198 the target process.
199 If
200 .I file
201 is specified, enter the user namespace specified by
202 .IR file .
203 See also the \fB\-\-setuid\fR and \fB\-\-setgid\fR options.
204 .TP
205 \fB\-C\fR, \fB\-\-cgroup\fR[=\fIfile\fR]
206 Enter the cgroup namespace. If no file is specified, enter the cgroup namespace of
207 the target process.
208 If
209 .I file
210 is specified, enter the cgroup namespace specified by
211 .IR file .
212 .TP
213 \fB\-G\fR, \fB\-\-setgid\fR \fIgid\fR
214 Set the group ID which will be used in the entered namespace and drop
215 supplementary groups.
216 .BR nsenter (1)
217 always sets GID for user namespaces, the default is 0.
218 .TP
219 \fB\-S\fR, \fB\-\-setuid\fR \fIuid\fR
220 Set the user ID which will be used in the entered namespace.
221 .BR nsenter (1)
222 always sets UID for user namespaces, the default is 0.
223 .TP
224 \fB\-\-preserve\-credentials\fR
225 Don't modify UID and GID when enter user namespace. The default is to
226 drops supplementary groups and sets GID and UID to 0.
227 .TP
228 \fB\-r\fR, \fB\-\-root\fR[=\fIdirectory\fR]
229 Set the root directory. If no directory is specified, set the root directory to
230 the root directory of the target process. If directory is specified, set the
231 root directory to the specified directory.
232 .TP
233 \fB\-w\fR, \fB\-\-wd\fR[=\fIdirectory\fR]
234 Set the working directory. If no directory is specified, set the working
235 directory to the working directory of the target process. If directory is
236 specified, set the working directory to the specified directory.
237 .TP
238 \fB\-F\fR, \fB\-\-no\-fork\fR
239 Do not fork before exec'ing the specified program. By default, when entering a
240 PID namespace, \fBnsenter\fP calls \fBfork\fP before calling \fBexec\fP so that
241 any children will also be in the newly entered PID namespace.
242 .TP
243 \fB\-Z\fR, \fB\-\-follow\-context\fR
244 Set the SELinux security context used for executing a new process according to
245 already running process specified by \fB\-\-target\fR PID. (The util-linux has
246 to be compiled with SELinux support otherwise the option is unavailable.)
247 .TP
248 \fB\-V\fR, \fB\-\-version\fR
249 Display version information and exit.
250 .TP
251 \fB\-h\fR, \fB\-\-help\fR
252 Display help text and exit.
253 .SH SEE ALSO
254 .BR clone (2),
255 .BR setns (2),
256 .BR namespaces (7)
257 .SH AUTHORS
258 .UR biederm@xmission.com
259 Eric Biederman
260 .UE
261 .br
262 .UR kzak@redhat.com
263 Karel Zak
264 .UE
265 .SH AVAILABILITY
266 The nsenter command is part of the util-linux package and is available from
267 .UR https://\:www.kernel.org\:/pub\:/linux\:/utils\:/util-linux/
268 Linux Kernel Archive
269 .UE .