How to display the PGID of running processes?

Asked

Viewed 134 times

2

On Linux, I’d like to know which command I use to display the PGID of the proceedings under implementation.

I saw in a reply here on Soept that we could kill a process (command Kill) using the process PGID. But using the command ps I only see the PID.

  • It is also possible to kill the process using the PID. Why specifically use the PGID? It is to kill all processes of a group of users?

  • 1

    My question started here: http://answall.com/questions/3522/comolidar-com-um-processo-comet/

2 answers

3


You can use the ps even, passing the option j. 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

2

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

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

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

Call with the PGID:

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

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

Most 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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.