Skip to main content
added 134 characters in body
Source Link
Stéphane Chazelas
  • 584.9k
  • 96
  • 1.1k
  • 1.7k

ps now has output options for the different types of namespaces associated with processes: ipcns, mntns, netns, pidns, userns, and utsns. For this question, the relevant one is the PID namespace, or pidns.

so if you wanted to find out the PID namespace id for, e.g., pid 459:

# ps -h -o pidns -p 459
4026532661

and to list all processes in that namespace:

ps -o pidns,pid,cmd | awk '$1==4026532661'

or with pgrep, you can go directly from a PID to a list of all processes sharing that same PID namespace:

pgrep -a --ns 459

Unlike ps, pgrep can limit the output to a specific namespace (if you know the PID of one of the processes in it), but has very limited output formatting capabilities (PIDs only, or PIDs and their command lines)

You can always pipe the output of pgrep --ns 459 to xargs ps -f though to retrieve the information you need about the process.

ps now has output options for the different types of namespaces associated with processes: ipcns, mntns, netns, pidns, userns, and utsns. For this question, the relevant one is the PID namespace, or pidns.

so if you wanted to find out the PID namespace id for, e.g., pid 459:

# ps -h -o pidns -p 459
4026532661

and to list all processes in that namespace:

ps -o pidns,pid,cmd | awk '$1==4026532661'

or with pgrep, you can go directly from a PID to a list of all processes sharing that same PID namespace:

pgrep -a --ns 459

Unlike ps, pgrep can limit the output to a specific namespace (if you know the PID of one of the processes in it), but has very limited output formatting capabilities (PIDs only, or PIDs and their command lines)

ps now has output options for the different types of namespaces associated with processes: ipcns, mntns, netns, pidns, userns, and utsns. For this question, the relevant one is the PID namespace, or pidns.

so if you wanted to find out the PID namespace id for, e.g., pid 459:

# ps -h -o pidns -p 459
4026532661

and to list all processes in that namespace:

ps -o pidns,pid,cmd | awk '$1==4026532661'

or with pgrep, you can go directly from a PID to a list of all processes sharing that same PID namespace:

pgrep -a --ns 459

Unlike ps, pgrep can limit the output to a specific namespace (if you know the PID of one of the processes in it), but has very limited output formatting capabilities (PIDs only, or PIDs and their command lines)

You can always pipe the output of pgrep --ns 459 to xargs ps -f though to retrieve the information you need about the process.

Source Link
cas
  • 84.4k
  • 9
  • 136
  • 205

ps now has output options for the different types of namespaces associated with processes: ipcns, mntns, netns, pidns, userns, and utsns. For this question, the relevant one is the PID namespace, or pidns.

so if you wanted to find out the PID namespace id for, e.g., pid 459:

# ps -h -o pidns -p 459
4026532661

and to list all processes in that namespace:

ps -o pidns,pid,cmd | awk '$1==4026532661'

or with pgrep, you can go directly from a PID to a list of all processes sharing that same PID namespace:

pgrep -a --ns 459

Unlike ps, pgrep can limit the output to a specific namespace (if you know the PID of one of the processes in it), but has very limited output formatting capabilities (PIDs only, or PIDs and their command lines)