How to display the PGID of running processes?

2

On Linux, I would like to know which command I use to display the PGID of running processes.

I saw in an answer here in SOePT that we could kill a process (kill command) using the PGID of the process. But using the command ps I see only the PID.

    
asked by anonymous 19.02.2014 / 18:50

2 answers

3

You can use ps yourself by passing the j option. In the example below the -e is used to show all processes.

ps -ej

If you want to know more, see man of ps :

man ps
    
19.02.2014 / 20:42
2

I'll show you just one more way to do that I found. It's very flexible:

Using the command ps same. But passing options to the command. This is the signature of the call:

ps o <campos a ser exibido>

Examples:

Simple call:

[root@alab ~]# ps
  PID TTY          TIME CMD
 1946 pts/0    00:00:00 bash
 1966 pts/0    00:00:00 ps

Calling with PGID:

[root@alab ~]# ps o pgid
 PGID
 1463
 1465
 1467
 1469
 1475
 1582
 1946
 1970

Note that when we pass o , we must tell exactly which columns we want to display. So to get something more complete and add the PGID we can use the command as follows:

More complete call:

[root@alab ~]# ps axo pid,pgid,tty,time,comm
  PID  PGID TT           TIME COMMAND
    1     1 ?        00:00:00 init
    2     0 ?        00:00:00 kthreadd
    [...cut...]
 1463  1463 tty2     00:00:00 mingetty
 1465  1465 tty3     00:00:00 mingetty
 1467  1467 tty4     00:00:00 mingetty
 1469  1469 tty5     00:00:00 mingetty
 1473   470 ?        00:00:00 udevd
 1474   470 ?        00:00:00 udevd
 1475  1475 tty6     00:00:00 mingetty
 1493  1493 ?        00:00:00 auditd
 1516  1159 ?        00:00:00 console-kit-dae
 1582  1582 tty1     00:00:00 bash
 1894  1894 ?        00:00:00 dhclient
 1942  1942 ?        00:00:00 sshd
 1946  1946 pts/0    00:00:00 bash
 1975  1975 pts/0    00:00:00 ps
    
20.02.2014 / 14:41