{
    "content": [
        {
            "type": "text",
            "text": "# nsenter (man)\n\n## NAME\n\nnsenter - run program in different namespaces\n\n## SYNOPSIS\n\nnsenter [options] [program [arguments]]\n\n## DESCRIPTION\n\nThe nsenter command executes program in the namespace(s) that are specified in the\ncommand-line options (described below). If program is not given, then \"${SHELL}\" is run\n(default: /bin/sh).\n\n## TLDR\n\n> Run a new command in a running process' namespace.\n\n- Run a specific command using the same namespaces as an existing process:\n  `nsenter {{-t|--target}} {{pid}} {{-a|--all}} {{command}} {{command_arguments}}`\n- Run a specific command in an existing process's mount|UTS|IPC|network|PID|user|cgroup|time namespace:\n  `nsenter {{-t|--target}} {{pid}} --{{mount|uts|ipc|net|pid|user|cgroup}} {{command}} {{command_arguments}}`\n- Run a specific command in an existing process's UTS, time, and IPC namespaces:\n  `nsenter {{-t|--target}} {{pid}} {{-u|--uts}} {{-T|--time}} {{-i|--ipc}} -- {{command}} {{command_arguments}}`\n- Run a specific command in an existing process's namespace by referencing procfs:\n  `nsenter {{-p|--pid=}}/proc/{{pid}}/pid/net -- {{command}} {{command_arguments}}`\n\n*Source: tldr-pages*\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION** (8 subsections)\n- **OPTIONS** (19 subsections)\n- **AUTHORS**\n- **SEE ALSO**\n- **REPORTING BUGS**\n- **AVAILABILITY**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "nsenter",
        "section": "",
        "mode": "man",
        "summary": "nsenter - run program in different namespaces",
        "synopsis": "nsenter [options] [program [arguments]]",
        "tldr_summary": "Run a new command in a running process' namespace.",
        "tldr_examples": [
            {
                "description": "Run a specific command using the same namespaces as an existing process",
                "command": "nsenter {{-t|--target}} {{pid}} {{-a|--all}} {{command}} {{command_arguments}}"
            },
            {
                "description": "Run a specific command in an existing process's mount|UTS|IPC|network|PID|user|cgroup|time namespace",
                "command": "nsenter {{-t|--target}} {{pid}} --{{mount|uts|ipc|net|pid|user|cgroup}} {{command}} {{command_arguments}}"
            },
            {
                "description": "Run a specific command in an existing process's UTS, time, and IPC namespaces",
                "command": "nsenter {{-t|--target}} {{pid}} {{-u|--uts}} {{-T|--time}} {{-i|--ipc}} -- {{command}} {{command_arguments}}"
            },
            {
                "description": "Run a specific command in an existing process's namespace by referencing procfs",
                "command": "nsenter {{-p|--pid=}}/proc/{{pid}}/pid/net -- {{command}} {{command_arguments}}"
            }
        ],
        "tldr_source": "official",
        "flags": [
            {
                "flag": "-a",
                "long": "--all",
                "arg": null,
                "description": "Enter all namespaces of the target process by the default /proc/[pid]/ns/* namespace paths. The default paths to the target process namespaces may be overwritten by namespace specific options (e.g., --all --mount=[path]). The user namespace will be ignored if the same as the caller’s current user namespace. It prevents a caller that has dropped capabilities from regaining those capabilities via a call to setns(). See setns(2) for more details."
            },
            {
                "flag": "-t",
                "long": "--target",
                "arg": null,
                "description": "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/ns/time the time namespace /proc/pid/root the root directory /proc/pid/cwd the working directory respectively"
            },
            {
                "flag": "-m",
                "long": "--mount",
                "arg": null,
                "description": "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."
            },
            {
                "flag": "-u",
                "long": "--uts",
                "arg": null,
                "description": "Enter the UTS namespace. If no file is specified, enter the UTS namespace of the target process. If file is specified, enter the UTS namespace specified by file."
            },
            {
                "flag": "-i",
                "long": "--ipc",
                "arg": null,
                "description": "Enter the IPC namespace. If no file is specified, enter the IPC namespace of the target process. If file is specified, enter the IPC namespace specified by file."
            },
            {
                "flag": "-n",
                "long": "--net",
                "arg": null,
                "description": "Enter the network namespace. If no file is specified, enter the network namespace of the target process. If file is specified, enter the network namespace specified by file."
            },
            {
                "flag": "-p",
                "long": "--pid",
                "arg": null,
                "description": "Enter the PID namespace. If no file is specified, enter the PID namespace of the target process. If file is specified, enter the PID namespace specified by file."
            },
            {
                "flag": "-U",
                "long": "--user",
                "arg": null,
                "description": "Enter the user namespace. If no file is specified, enter the user namespace of the target process. If file is specified, enter the user namespace specified by file. See also the --setuid and --setgid options."
            },
            {
                "flag": "-C",
                "long": "--cgroup",
                "arg": null,
                "description": "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."
            },
            {
                "flag": "-T",
                "long": "--time",
                "arg": null,
                "description": "Enter the time namespace. If no file is specified, enter the time namespace of the target process. If file is specified, enter the time namespace specified by file."
            },
            {
                "flag": "-G",
                "long": "--setgid",
                "arg": null,
                "description": "Set the group ID which will be used in the entered namespace and drop supplementary groups. nsenter always sets GID for user namespaces, the default is 0."
            },
            {
                "flag": "-S",
                "long": "--setuid",
                "arg": null,
                "description": "Set the user ID which will be used in the entered namespace. nsenter always sets UID for user namespaces, the default is 0."
            },
            {
                "flag": "",
                "long": "--preserve-credentials",
                "arg": null,
                "description": "Don’t modify UID and GID when enter user namespace. The default is to drops supplementary groups and sets GID and UID to 0."
            },
            {
                "flag": "-r",
                "long": "--root",
                "arg": null,
                "description": "Set the root directory. If no directory is specified, set the root directory to the root directory of the target process. If directory is specified, set the root directory to the specified directory."
            },
            {
                "flag": "-w",
                "long": "--wd",
                "arg": null,
                "description": "Set the working directory. If no directory is specified, set the working directory to the working directory of the target process. If directory is specified, set the working directory to the specified directory."
            },
            {
                "flag": "-F",
                "long": "--no-fork",
                "arg": null,
                "description": "Do not fork before exec’ing the specified program. By default, when entering a PID namespace, nsenter calls fork before calling exec so that any children will also be in the newly entered PID namespace."
            },
            {
                "flag": "-Z",
                "long": "--follow-context",
                "arg": null,
                "description": "Set the SELinux security context used for executing a new process according to already running process specified by --target PID. (The util-linux has to be compiled with SELinux support otherwise the option is unavailable.)"
            },
            {
                "flag": "-V",
                "long": "--version",
                "arg": null,
                "description": "Display version information and exit."
            },
            {
                "flag": "-h",
                "long": "--help",
                "arg": null,
                "description": "Display help text and exit."
            }
        ],
        "examples": [],
        "see_also": [
            {
                "name": "clone",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/clone/2/json"
            },
            {
                "name": "setns",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/setns/2/json"
            },
            {
                "name": "namespaces",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/namespaces/7/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 6,
                "subsections": [
                    {
                        "name": "mount namespace",
                        "lines": 5
                    },
                    {
                        "name": "UTS namespace",
                        "lines": 3
                    },
                    {
                        "name": "IPC namespace",
                        "lines": 4
                    },
                    {
                        "name": "network namespace",
                        "lines": 4
                    },
                    {
                        "name": "PID namespace",
                        "lines": 6
                    },
                    {
                        "name": "user namespace",
                        "lines": 3
                    },
                    {
                        "name": "cgroup namespace",
                        "lines": 3
                    },
                    {
                        "name": "time namespace",
                        "lines": 3
                    }
                ]
            },
            {
                "name": "OPTIONS",
                "lines": 4,
                "subsections": [
                    {
                        "name": "-a --all",
                        "lines": 8,
                        "flag": "-a",
                        "long": "--all"
                    },
                    {
                        "name": "-t --target",
                        "lines": 33,
                        "flag": "-t",
                        "long": "--target"
                    },
                    {
                        "name": "-m --mount",
                        "lines": 3,
                        "flag": "-m",
                        "long": "--mount"
                    },
                    {
                        "name": "-u --uts",
                        "lines": 3,
                        "flag": "-u",
                        "long": "--uts"
                    },
                    {
                        "name": "-i --ipc",
                        "lines": 3,
                        "flag": "-i",
                        "long": "--ipc"
                    },
                    {
                        "name": "-n --net",
                        "lines": 3,
                        "flag": "-n",
                        "long": "--net"
                    },
                    {
                        "name": "-p --pid",
                        "lines": 3,
                        "flag": "-p",
                        "long": "--pid"
                    },
                    {
                        "name": "-U --user",
                        "lines": 4,
                        "flag": "-U",
                        "long": "--user"
                    },
                    {
                        "name": "-C --cgroup",
                        "lines": 3,
                        "flag": "-C",
                        "long": "--cgroup"
                    },
                    {
                        "name": "-T --time",
                        "lines": 3,
                        "flag": "-T",
                        "long": "--time"
                    },
                    {
                        "name": "-G --setgid",
                        "lines": 3,
                        "flag": "-G",
                        "long": "--setgid"
                    },
                    {
                        "name": "-S --setuid",
                        "lines": 3,
                        "flag": "-S",
                        "long": "--setuid"
                    },
                    {
                        "name": "--preserve-credentials",
                        "lines": 3,
                        "long": "--preserve-credentials"
                    },
                    {
                        "name": "-r --root",
                        "lines": 4,
                        "flag": "-r",
                        "long": "--root"
                    },
                    {
                        "name": "-w --wd",
                        "lines": 4,
                        "flag": "-w",
                        "long": "--wd"
                    },
                    {
                        "name": "-F --no-fork",
                        "lines": 4,
                        "flag": "-F",
                        "long": "--no-fork"
                    },
                    {
                        "name": "-Z --follow-context",
                        "lines": 4,
                        "flag": "-Z",
                        "long": "--follow-context"
                    },
                    {
                        "name": "-V --version",
                        "lines": 2,
                        "flag": "-V",
                        "long": "--version"
                    },
                    {
                        "name": "-h --help",
                        "lines": 2,
                        "flag": "-h",
                        "long": "--help"
                    }
                ]
            },
            {
                "name": "AUTHORS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "REPORTING BUGS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "AVAILABILITY",
                "lines": 6,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "nsenter - run program in different namespaces\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "nsenter [options] [program [arguments]]\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "The nsenter command executes program in the namespace(s) that are specified in the\ncommand-line options (described below). If program is not given, then \"${SHELL}\" is run\n(default: /bin/sh).\n\nEnterable namespaces are:\n",
                "subsections": [
                    {
                        "name": "mount namespace",
                        "content": "Mounting and unmounting filesystems will not affect the rest of the system, except for\nfilesystems which are explicitly marked as shared (with mount --make-shared; see\n/proc/self/mountinfo for the shared flag). For further details, see mountnamespaces(7)\nand the discussion of the CLONENEWNS flag in clone(2).\n"
                    },
                    {
                        "name": "UTS namespace",
                        "content": "Setting hostname or domainname will not affect the rest of the system. For further\ndetails, see utsnamespaces(7).\n"
                    },
                    {
                        "name": "IPC namespace",
                        "content": "The process will have an independent namespace for POSIX message queues as well as System\nV message queues, semaphore sets and shared memory segments. For further details, see\nipcnamespaces(7).\n"
                    },
                    {
                        "name": "network namespace",
                        "content": "The process will have independent IPv4 and IPv6 stacks, IP routing tables, firewall\nrules, the /proc/net and /sys/class/net directory trees, sockets, etc. For further\ndetails, see networknamespaces(7).\n"
                    },
                    {
                        "name": "PID namespace",
                        "content": "Children will have a set of PID to process mappings separate from the nsenter process.\nnsenter will fork by default if changing the PID namespace, so that the new program and\nits children share the same PID namespace and are visible to each other. If --no-fork is\nused, the new program will be exec’ed without forking. For further details, see\npidnamespaces(7).\n"
                    },
                    {
                        "name": "user namespace",
                        "content": "The process will have a distinct set of UIDs, GIDs and capabilities. For further details,\nsee usernamespaces(7).\n"
                    },
                    {
                        "name": "cgroup namespace",
                        "content": "The process will have a virtualized view of /proc/self/cgroup, and new cgroup mounts will\nbe rooted at the namespace cgroup root. For further details, see cgroupnamespaces(7).\n"
                    },
                    {
                        "name": "time namespace",
                        "content": "The process can have a distinct view of CLOCKMONOTONIC and/or CLOCKBOOTTIME which can\nbe changed using /proc/self/timensoffsets. For further details, see timenamespaces(7).\n"
                    }
                ]
            },
            "OPTIONS": {
                "content": "Various of the options below that relate to namespaces take an optional file argument. This\nshould be one of the /proc/[pid]/ns/* files described in namespaces(7), or the pathname of a\nbind mount that was created on one of those files.\n",
                "subsections": [
                    {
                        "name": "-a --all",
                        "content": "Enter all namespaces of the target process by the default /proc/[pid]/ns/* namespace\npaths. The default paths to the target process namespaces may be overwritten by namespace\nspecific options (e.g., --all --mount=[path]).\n\nThe user namespace will be ignored if the same as the caller’s current user namespace. It\nprevents a caller that has dropped capabilities from regaining those capabilities via a\ncall to setns(). See setns(2) for more details.\n",
                        "flag": "-a",
                        "long": "--all"
                    },
                    {
                        "name": "-t --target",
                        "content": "Specify a target process to get contexts from. The paths to the contexts specified by pid\nare:\n\n/proc/pid/ns/mnt\nthe mount namespace\n\n/proc/pid/ns/uts\nthe UTS namespace\n\n/proc/pid/ns/ipc\nthe IPC namespace\n\n/proc/pid/ns/net\nthe network namespace\n\n/proc/pid/ns/pid\nthe PID namespace\n\n/proc/pid/ns/user\nthe user namespace\n\n/proc/pid/ns/cgroup\nthe cgroup namespace\n\n/proc/pid/ns/time\nthe time namespace\n\n/proc/pid/root\nthe root directory\n\n/proc/pid/cwd\nthe working directory respectively\n",
                        "flag": "-t",
                        "long": "--target"
                    },
                    {
                        "name": "-m --mount",
                        "content": "Enter the mount namespace. If no file is specified, enter the mount namespace of the\ntarget process. If file is specified, enter the mount namespace specified by file.\n",
                        "flag": "-m",
                        "long": "--mount"
                    },
                    {
                        "name": "-u --uts",
                        "content": "Enter the UTS namespace. If no file is specified, enter the UTS namespace of the target\nprocess. If file is specified, enter the UTS namespace specified by file.\n",
                        "flag": "-u",
                        "long": "--uts"
                    },
                    {
                        "name": "-i --ipc",
                        "content": "Enter the IPC namespace. If no file is specified, enter the IPC namespace of the target\nprocess. If file is specified, enter the IPC namespace specified by file.\n",
                        "flag": "-i",
                        "long": "--ipc"
                    },
                    {
                        "name": "-n --net",
                        "content": "Enter the network namespace. If no file is specified, enter the network namespace of the\ntarget process. If file is specified, enter the network namespace specified by file.\n",
                        "flag": "-n",
                        "long": "--net"
                    },
                    {
                        "name": "-p --pid",
                        "content": "Enter the PID namespace. If no file is specified, enter the PID namespace of the target\nprocess. If file is specified, enter the PID namespace specified by file.\n",
                        "flag": "-p",
                        "long": "--pid"
                    },
                    {
                        "name": "-U --user",
                        "content": "Enter the user namespace. If no file is specified, enter the user namespace of the target\nprocess. If file is specified, enter the user namespace specified by file. See also the\n--setuid and --setgid options.\n",
                        "flag": "-U",
                        "long": "--user"
                    },
                    {
                        "name": "-C --cgroup",
                        "content": "Enter the cgroup namespace. If no file is specified, enter the cgroup namespace of the\ntarget process. If file is specified, enter the cgroup namespace specified by file.\n",
                        "flag": "-C",
                        "long": "--cgroup"
                    },
                    {
                        "name": "-T --time",
                        "content": "Enter the time namespace. If no file is specified, enter the time namespace of the target\nprocess. If file is specified, enter the time namespace specified by file.\n",
                        "flag": "-T",
                        "long": "--time"
                    },
                    {
                        "name": "-G --setgid",
                        "content": "Set the group ID which will be used in the entered namespace and drop supplementary\ngroups. nsenter always sets GID for user namespaces, the default is 0.\n",
                        "flag": "-G",
                        "long": "--setgid"
                    },
                    {
                        "name": "-S --setuid",
                        "content": "Set the user ID which will be used in the entered namespace. nsenter always sets UID for\nuser namespaces, the default is 0.\n",
                        "flag": "-S",
                        "long": "--setuid"
                    },
                    {
                        "name": "--preserve-credentials",
                        "content": "Don’t modify UID and GID when enter user namespace. The default is to drops supplementary\ngroups and sets GID and UID to 0.\n",
                        "long": "--preserve-credentials"
                    },
                    {
                        "name": "-r --root",
                        "content": "Set the root directory. If no directory is specified, set the root directory to the root\ndirectory of the target process. If directory is specified, set the root directory to the\nspecified directory.\n",
                        "flag": "-r",
                        "long": "--root"
                    },
                    {
                        "name": "-w --wd",
                        "content": "Set the working directory. If no directory is specified, set the working directory to the\nworking directory of the target process. If directory is specified, set the working\ndirectory to the specified directory.\n",
                        "flag": "-w",
                        "long": "--wd"
                    },
                    {
                        "name": "-F --no-fork",
                        "content": "Do not fork before exec’ing the specified program. By default, when entering a PID\nnamespace, nsenter calls fork before calling exec so that any children will also be in\nthe newly entered PID namespace.\n",
                        "flag": "-F",
                        "long": "--no-fork"
                    },
                    {
                        "name": "-Z --follow-context",
                        "content": "Set the SELinux security context used for executing a new process according to already\nrunning process specified by --target PID. (The util-linux has to be compiled with\nSELinux support otherwise the option is unavailable.)\n",
                        "flag": "-Z",
                        "long": "--follow-context"
                    },
                    {
                        "name": "-V --version",
                        "content": "Display version information and exit.\n",
                        "flag": "-V",
                        "long": "--version"
                    },
                    {
                        "name": "-h --help",
                        "content": "Display help text and exit.\n",
                        "flag": "-h",
                        "long": "--help"
                    }
                ]
            },
            "AUTHORS": {
                "content": "Eric Biederman <biederm@xmission.com>, Karel Zak <kzak@redhat.com>\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "clone(2), setns(2), namespaces(7)\n",
                "subsections": []
            },
            "REPORTING BUGS": {
                "content": "For bug reports, use the issue tracker at https://github.com/karelzak/util-linux/issues.\n",
                "subsections": []
            },
            "AVAILABILITY": {
                "content": "The nsenter command is part of the util-linux package which can be downloaded from Linux\nKernel Archive <https://www.kernel.org/pub/linux/utils/util-linux/>.\n\n\n\nutil-linux 2.37.2                            2021-06-02                                   NSENTER(1)",
                "subsections": []
            }
        }
    }
}