Linux command
nsenter 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Example
nsenter -t 1234 -a command
Example
nsenter -t 1234 --mount command
Example
nsenter -t 1234 --net command
Example
nsenter -t 1234 --pid command
Example
nsenter -t 1234 -u -T -i -- command
Example
nsenter --net=/proc/1234/ns/net command
说明
nsenter runs a program with namespaces of another process. It is particularly useful for entering Docker containers, debugging processes in different namespaces, or working with chroot jails. If no program is specified, it runs the default shell.
参数
- -t, --target pid
- Specify source process for namespace contexts
- -a, --all
- Enter all namespaces of the target process
- -m, --mount=file
- Enter mount namespace
- -u, --uts=file
- Enter UTS (hostname/domainname) namespace
- -i, --ipc=file
- Enter IPC namespace
- -n, --net=file
- Enter network namespace
- -p, --pid=file
- Enter PID namespace
- -U, --user=file
- Enter user namespace
- -C, --cgroup=file
- Enter cgroup namespace
- -T, --time=file
- Enter time namespace
- -S, --setuid uid
- Set user ID in entered namespace
- -G, --setgid gid
- Set group ID in entered namespace
- -F, --no-fork
- Do not fork before executing the program
- -w, --wd=directory
- Set working directory
- -r, --root=directory
- Set root directory
FAQ
What is the nsenter command used for?
nsenter runs a program with namespaces of another process. It is particularly useful for entering Docker containers, debugging processes in different namespaces, or working with chroot jails. If no program is specified, it runs the default shell.
How do I run a basic nsenter example?
Run `nsenter -t 1234 -a command` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -t, --target pid do in nsenter?
Specify source process for namespace contexts