Linux "nsenter" Command Line Options and Examples
run program with namespaces of other processes

Enters the namespaces of one or more other processes and then executes the specified program. If program is not given, then ``${SHELL}'' is run (default: /bin/sh).


Usage:

nsenter [options] [program [arguments]]




Command Line Options:

-a
Enter all namespaces of the target process by the default /proc/[pid]/ns/* namespace paths. The defaultpaths to the target process namespaces may be overwritten by namespace specific options (e.g. --all
nsenter -a ...
--mount
The user namespace will be ignored if the same as the caller's current user namespace. It prevents acaller that has dropped capabilities from regaining those capabilities via a call to setns(). Seesetns(2) for more details.
nsenter --mount ...
-t
Specify a target process to get contexts from. The paths to the contexts specified by pid are:/proc/pid/ns/mnt the mount namespace/proc/pid/ns/uts the UTS namespace/proc/pid/ns/ipc the IPC namespace/proc/pid/ns/net the network namespace/proc/pid/ns/pid the PID namespace/proc/pid/ns/user the user namespace/proc/pid/ns/cgroup the cgroup namespace/proc/pid/root the root directory/proc/pid/cwd the working directory respectively
nsenter -t ...
-m
Enter the mount namespace. If no file is specified, enter the mount namespace of the target process.If file is specified, enter the mount namespace specified by file.
nsenter -m ...
-u
Enter the UTS namespace. If no file is specified, enter the UTS namespace of the target process. Iffile is specified, enter the UTS namespace specified by file.
nsenter -u ...
-i
Enter the IPC namespace. If no file is specified, enter the IPC namespace of the target process. Iffile is specified, enter the IPC namespace specified by file.
nsenter -i ...
-n
Enter the network namespace. If no file is specified, enter the network namespace of the targetprocess. If file is specified, enter the network namespace specified by file.
nsenter -n ...
-p
Enter the PID namespace. If no file is specified, enter the PID namespace of the target process. Iffile is specified, enter the PID namespace specified by file.
nsenter -p ...
-U
Enter the user namespace. If no file is specified, enter the user namespace of the target process. Iffile is specified, enter the user namespace specified by file. See also the --setuid and --setgidoptions.
nsenter -U ...
-C
Enter the cgroup namespace. If no file is specified, enter the cgroup namespace of the target process.If file is specified, enter the cgroup namespace specified by file.
nsenter -C ...
-G
Set the group ID which will be used in the entered namespace and drop supplementary groups. nsenter(1)always sets GID for user namespaces, the default is 0.
nsenter -G ...
-S
Set the user ID which will be used in the entered namespace. nsenter(1) always sets UID for usernamespaces, the default is 0.
nsenter -S ...
--preserve-credentials
Don't modify UID and GID when enter user namespace. The default is to drops supplementary groups andsets GID and UID to 0.
nsenter --preserve-credentials ...
-r
Set the root directory. If no directory is specified, set the root directory to the root directory ofthe target process. If directory is specified, set the root directory to the specified directory.
nsenter -r ...
-w
Set the working directory. If no directory is specified, set the working directory to the workingdirectory of the target process. If directory is specified, set the working directory to the specifieddirectory.
nsenter -w ...
-F
Do not fork before exec'ing the specified program. By default, when entering a PID namespace, nsentercalls fork before calling exec so that any children will also be in the newly entered PID namespace.
nsenter -F ...
-Z
Set the SELinux security context used for executing a new process according to already running processspecified by --target PID. (The util-linux has to be compiled with SELinux support otherwise the optionis unavailable.)
nsenter -Z ...
-V
Display version information and exit.
nsenter -V ...
-h
Display help text and exit.
nsenter -h ...