'ps' arguments to display PID, PPID, PGID, and SID collectively

Here you go:

$ ps  xao pid,ppid,pgid,sid | head
  PID  PPID  PGID   SID
    1     0     1     1
    2     0     0     0
    3     2     0     0
    6     2     0     0
    7     2     0     0
   21     2     0     0
   22     2     0     0
   23     2     0     0
   24     2     0     0

If you want to see the process' name as well, use this:

$ ps  xao pid,ppid,pgid,sid,comm | head
  PID  PPID  PGID   SID COMMAND
    1     0     1     1 init
    2     0     0     0 kthreadd
    3     2     0     0 ksoftirqd/0
    6     2     0     0 migration/0
    7     2     0     0 watchdog/0
   21     2     0     0 cpuset
   22     2     0     0 khelper
   23     2     0     0 kdevtmpfs
   24     2     0     0 netns

Try

ps -efj | less

Specifically, if you want to find out PID/PGID/PPID/SID for a certain ProcessName or PID, Try:

ps -efj | grep ProcessName

ps -efj | grep PID

OR for better-formatted output, try:

ps -ejf | egrep 'STIME|ProcessName'

ps -ejf | egrep 'STIME|pid'

Examples:

ps -ejf | egrep 'STIME|http'

ps -ejf | egrep 'STIME|1234'

SAMPLE:

[ram@thinkred1cartoon ~]$ ps -ejf | egrep 'STIME|http'

UID        PID  PPID  PGID   SID  C STIME TTY          TIME CMD
root      1450     1  1450  1450  0 08:45 ?        00:00:04 /usr/sbin/httpd -DFOREGROUND
ram       3717     1  2589  2589  0 08:47 ?        00:00:00 /usr/libexec/gvfsd-http --spawner :1.3 /org/gtk/gvfs/exec_spaw/1
apache   11518  1450  1450  1450  0 09:40 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache   11519  1450  1450  1450  0 09:40 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache   11520  1450  1450  1450  0 09:40 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache   11521  1450  1450  1450  0 09:40 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache   11522  1450  1450  1450  0 09:40 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
Assuming 1234 is PID and you want to know its associated PPID, PGID, SID & CMD
Tested on CentOS/RedHat 6.x & 7.x

Tags:

Process

Ps