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