When using tools such as ps or top to show running processes in Linux or any other Unix-based operating systems, you're normally presented with all the processes in the system which could get a bit overwhelming.
Often times you need to drill down and just want to see running processes only from yourself or any other particular user. This is especially true if you're administering a server which allows remote access from multiple users.
You can use command line tools such as ps, top and pgrep to list running processes in Linux and to make them to only show processes from a specific user that you wish to target.
$ ps -u gdm -U gdm PID TTY TIME CMD 737 ? 00:00:00 systemd 738 ? 00:00:00 (sd-pam) 1260 ? 00:00:00 dbus-daemon 1271 tty1 00:00:00 gdm-x-session 1273 tty1 00:00:00 Xorg 1282 tty1 00:00:00 gnome-session-b 1284 ? 00:00:00 at-spi-bus-laun 1289 ? 00:00:00 dbus-daemon 1294 ? 00:00:00 pulseaudio 1298 ? 00:00:00 gnome-session-c 1306 ? 00:00:00 gnome-keyring-d 1312 ? 00:00:00 gnome-session-b 1321 ? 00:00:03 gnome-shell 1346 ? 00:00:00 xdg-permission- 1367 ? 00:00:00 ibus-daemon 1375 ? 00:00:00 ibus-memconf 1378 ? 00:00:00 ibus-x11 1382 ? 00:00:00 ibus-portal 1405 ? 00:00:00 at-spi2-registr 1415 ? 00:00:00 gsd-wwan 1416 ? 00:00:00 gsd-power 1417 ? 00:00:00 gsd-wacom 1420 ? 00:00:00 gsd-xsettings 1421 ? 00:00:00 gsd-color 1430 ? 00:00:00 gsd-keyboard 1434 ? 00:00:00 gsd-rfkill 1436 ? 00:00:00 gsd-a11y-settin 1442 ? 00:00:00 gsd-media-keys 1448 ? 00:00:00 gsd-smartcard 1453 ? 00:00:00 gsd-sound 1461 ? 00:00:00 gsd-print-notif 1484 ? 00:00:00 gsd-printer 1487 ? 00:00:00 ibus-engine-sim
$ ps -u gdm -U gdm -u root -U root PID TTY TIME CMD 1 ? 00:00:04 systemd 2 ? 00:00:00 kthreadd 3 ? 00:00:00 rcu_gp 4 ? 00:00:00 rcu_par_gp 6 ? 00:00:00 kworker/0:0H-kblockd 7 ? 00:00:00 kworker/0:1-events 9 ? 00:00:00 mm_percpu_wq 10 ? 00:00:00 ksoftirqd/0 11 ? 00:00:00 rcu_sched 12 ? 00:00:00 migration/0 13 ? 00:00:00 idle_inject/0 14 ? 00:00:00 cpuhp/0 15 ? 00:00:00 kdevtmpfs 16 ? 00:00:00 netns 17 ? 00:00:00 rcu_tasks_kthre 18 ? 00:00:00 kauditd 19 ? 00:00:00 khungtaskd 20 ? 00:00:00 oom_reaper 21 ? 00:00:00 writeback 22 ? 00:00:00 kcompactd0 23 ? 00:00:00 ksmd 24 ? 00:00:00 khugepaged 26 ? 00:00:00 kworker/u256:1-events_unbound 116 ? 00:00:00 kintegrityd 117 ? 00:00:00 kblockd 118 ? 00:00:00 blkcg_punt_bio 119 ? 00:00:00 tpm_dev_wq 120 ? 00:00:00 ata_sff 121 ? 00:00:00 md 122 ? 00:00:00 edac-poller 123 ? 00:00:00 devfreq_wq 124 ? 00:00:00 watchdogd 127 ? 00:00:00 kswapd0 128 ? 00:00:00 kworker/u257:0-hci0 129 ? 00:00:00 ecryptfs-kthrea 132 ? 00:00:00 kthrotld 133 ? 00:00:00 irq/24-pciehp 134 ? 00:00:00 irq/25-pciehp 135 ? 00:00:00 irq/26-pciehp 136 ? 00:00:00 irq/27-pciehp 137 ? 00:00:00 irq/28-pciehp 138 ? 00:00:00 irq/29-pciehp 139 ? 00:00:00 irq/30-pciehp 140 ? 00:00:00 irq/31-pciehp 141 ? 00:00:00 irq/32-pciehp 142 ? 00:00:00 irq/33-pciehp 143 ? 00:00:00 irq/34-pciehp 144 ? 00:00:00 irq/35-pciehp 145 ? 00:00:00 irq/36-pciehp 146 ? 00:00:00 irq/37-pciehp 147 ? 00:00:00 irq/38-pciehp 148 ? 00:00:00 irq/39-pciehp 149 ? 00:00:00 irq/40-pciehp 150 ? 00:00:00 irq/41-pciehp 151 ? 00:00:00 irq/42-pciehp 152 ? 00:00:00 irq/43-pciehp 153 ? 00:00:00 irq/44-pciehp 154 ? 00:00:00 irq/45-pciehp 155 ? 00:00:00 irq/46-pciehp 156 ? 00:00:00 irq/47-pciehp 157 ? 00:00:00 irq/48-pciehp 158 ? 00:00:00 irq/49-pciehp 159 ? 00:00:00 irq/50-pciehp 160 ? 00:00:00 irq/51-pciehp 161 ? 00:00:00 irq/52-pciehp 162 ? 00:00:00 irq/53-pciehp 163 ? 00:00:00 irq/54-pciehp 164 ? 00:00:00 irq/55-pciehp 165 ? 00:00:00 acpi_thermal_pm 166 ? 00:00:00 scsi_eh_0 167 ? 00:00:00 scsi_tmf_0 168 ? 00:00:00 scsi_eh_1 169 ? 00:00:00 scsi_tmf_1 171 ? 00:00:00 ipv6_addrconf 183 ? 00:00:00 kstrp 202 ? 00:00:00 charger_manager 233 ? 00:00:00 kworker/0:3-events 245 ? 00:00:00 mpt_poll_0 246 ? 00:00:00 mpt/0 247 ? 00:00:00 scsi_eh_2 248 ? 00:00:00 scsi_tmf_2 249 ? 00:00:00 scsi_eh_3 250 ? 00:00:00 scsi_tmf_3 251 ? 00:00:00 scsi_eh_4 252 ? 00:00:00 scsi_tmf_4 253 ? 00:00:00 scsi_eh_5 254 ? 00:00:00 scsi_tmf_5 255 ? 00:00:00 scsi_eh_6 256 ? 00:00:00 scsi_tmf_6 257 ? 00:00:00 scsi_eh_7 258 ? 00:00:00 scsi_tmf_7 259 ? 00:00:00 scsi_eh_8 260 ? 00:00:00 scsi_tmf_8 261 ? 00:00:00 scsi_eh_9 262 ? 00:00:00 scsi_tmf_9 263 ? 00:00:00 scsi_eh_10 264 ? 00:00:00 scsi_tmf_10 265 ? 00:00:00 scsi_eh_11 266 ? 00:00:00 scsi_tmf_11 267 ? 00:00:00 scsi_eh_12 268 ? 00:00:00 scsi_tmf_12 269 ? 00:00:00 scsi_eh_13 270 ? 00:00:00 scsi_tmf_13 271 ? 00:00:00 scsi_eh_14 272 ? 00:00:00 scsi_tmf_14 273 ? 00:00:00 scsi_eh_15 274 ? 00:00:00 scsi_eh_16 275 ? 00:00:00 scsi_tmf_16 276 ? 00:00:00 scsi_tmf_15 277 ? 00:00:00 scsi_eh_17 278 ? 00:00:00 scsi_tmf_17 279 ? 00:00:00 scsi_eh_18 280 ? 00:00:00 scsi_tmf_18 281 ? 00:00:00 scsi_eh_19 282 ? 00:00:00 scsi_tmf_19 283 ? 00:00:00 scsi_eh_20 284 ? 00:00:00 scsi_tmf_20 285 ? 00:00:00 scsi_eh_21 286 ? 00:00:00 scsi_tmf_21 287 ? 00:00:00 scsi_eh_22 288 ? 00:00:00 scsi_tmf_22 289 ? 00:00:00 scsi_eh_23 290 ? 00:00:00 scsi_tmf_23 291 ? 00:00:00 scsi_eh_24 292 ? 00:00:00 scsi_tmf_24 293 ? 00:00:00 scsi_eh_25 294 ? 00:00:00 scsi_tmf_25 295 ? 00:00:00 scsi_eh_26 296 ? 00:00:00 scsi_tmf_26 297 ? 00:00:00 scsi_eh_27 298 ? 00:00:00 scsi_tmf_27 299 ? 00:00:00 scsi_eh_28 300 ? 00:00:00 scsi_tmf_28 301 ? 00:00:00 scsi_eh_29 302 ? 00:00:00 scsi_tmf_29 303 ? 00:00:00 scsi_eh_30 304 ? 00:00:00 scsi_tmf_30 305 ? 00:00:00 scsi_eh_31 306 ? 00:00:00 scsi_tmf_31 307 ? 00:00:00 scsi_eh_32 308 ? 00:00:00 scsi_tmf_32 332 ? 00:00:00 kworker/u256:28-flush-0:52 333 ? 00:00:00 kworker/u256:29-events_power_efficient 337 ? 00:00:01 kworker/0:1H-kblockd 360 ? 00:00:00 jbd2/sda1-8 361 ? 00:00:00 ext4-rsv-conver 408 ? 00:00:01 systemd-journal 421 ? 00:00:00 irq/16-vmwgfx 422 ? 00:00:00 systemd-udevd 423 ? 00:00:00 ttm_swap 435 ? 00:00:00 loop0 438 ? 00:00:00 vmware-vmblock- 441 ? 00:00:00 loop1 444 ? 00:00:00 loop2 446 ? 00:00:00 loop3 447 ? 00:00:00 loop4 454 ? 00:00:00 loop5 457 ? 00:00:00 loop6 459 ? 00:00:00 loop7 465 ? 00:00:00 loop8 467 ? 00:00:00 loop9 514 ? 00:00:00 VGAuthService 517 ? 00:00:00 vmtoolsd 554 ? 00:00:00 NetworkManager 563 ? 00:00:00 udisksd 571 ? 00:00:00 ModemManager 573 ? 00:00:00 networkd-dispat 584 ? 00:00:00 accounts-daemon 591 ? 00:00:00 systemd-logind 592 ? 00:00:04 snapd 602 ? 00:00:00 cron 606 ? 00:00:00 acpid 607 ? 00:00:00 wpa_supplicant 668 ? 00:00:00 polkitd 684 ? 00:00:00 cupsd 689 ? 00:00:00 cups-browsed 699 ? 00:00:00 gdm3 710 ? 00:00:00 unattended-upgr 737 ? 00:00:00 systemd 738 ? 00:00:00 (sd-pam) 984 ? 00:00:00 kworker/u257:2-hci0 1000 ? 00:00:00 cryptd 1148 ? 00:00:00 bluetoothd 1216 ? 00:00:00 loop10 1258 ? 00:00:00 gdm-session-wor 1260 ? 00:00:00 dbus-daemon 1271 tty1 00:00:00 gdm-x-session 1273 tty1 00:00:00 Xorg 1282 tty1 00:00:00 gnome-session-b 1284 ? 00:00:00 at-spi-bus-laun 1289 ? 00:00:00 dbus-daemon 1294 ? 00:00:00 pulseaudio 1298 ? 00:00:00 gnome-session-c 1306 ? 00:00:00 gnome-keyring-d 1312 ? 00:00:00 gnome-session-b 1321 ? 00:00:03 gnome-shell 1346 ? 00:00:00 xdg-permission- 1352 ? 00:00:00 upowerd 1357 ? 00:00:06 packagekitd 1367 ? 00:00:00 ibus-daemon 1375 ? 00:00:00 ibus-memconf 1378 ? 00:00:00 ibus-x11 1382 ? 00:00:00 ibus-portal 1405 ? 00:00:00 at-spi2-registr 1415 ? 00:00:00 gsd-wwan 1416 ? 00:00:00 gsd-power 1417 ? 00:00:00 gsd-wacom 1420 ? 00:00:00 gsd-xsettings 1421 ? 00:00:00 gsd-color 1430 ? 00:00:00 gsd-keyboard 1434 ? 00:00:00 gsd-rfkill 1436 ? 00:00:00 gsd-a11y-settin 1442 ? 00:00:00 gsd-media-keys 1448 ? 00:00:00 gsd-smartcard 1453 ? 00:00:00 gsd-sound 1461 ? 00:00:00 gsd-print-notif 1484 ? 00:00:00 gsd-printer 1487 ? 00:00:00 ibus-engine-sim 1566 ? 00:00:00 gdm-session-wor 1620 ? 00:00:00 krfcommd 2339 ? 00:00:00 fwupd 2348 ? 00:00:00 boltd 3140 ? 00:00:00 sshd 4320 ? 00:00:00 sshd
$ ps -aef | grep avahi avahi 580 1 0 10:03 ? 00:00:00 avahi-daemon: running [host.local] avahi 657 580 0 10:03 ? 00:00:00 avahi-daemon: chroot helper user 4804 4647 0 10:21 pts/1 00:00:00 grep --color=auto avahi
$ top -u gdm top - 10:22:34 up 19 min, 2 users, load average: 0.01, 0.11, 0.28 Tasks: 306 total, 1 running, 305 sleeping, 0 stopped, 0 zombie %Cpu(s): 3.0 us, 0.3 sy, 0.0 ni, 96.6 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st MiB Mem : 3907.9 total, 1688.9 free, 1229.8 used, 989.2 buff/cache MiB Swap: 947.2 total, 947.2 free, 0.0 used. 2427.5 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 737 gdm 20 0 18620 9484 7564 S 0.0 0.2 0:00.47 systemd 738 gdm 20 0 102676 2828 20 S 0.0 0.1 0:00.00 (sd-pam) 1260 gdm 20 0 7508 4772 4020 S 0.0 0.1 0:00.08 dbus-daemon 1271 gdm 20 0 172508 6700 6052 S 0.0 0.2 0:00.00 gdm-x-session 1273 gdm 20 0 242544 48240 33340 S 0.0 1.2 0:00.56 Xorg 1282 gdm 20 0 274412 15696 14016 S 0.0 0.4 0:00.01 gnome-session-b 1284 gdm 20 0 309584 9276 8424 S 0.0 0.2 0:00.00 at-spi-bus-laun 1289 gdm 20 0 7204 4292 3856 S 0.0 0.1 0:00.00 dbus-daemon 1294 gdm 20 0 890912 17428 13716 S 0.0 0.4 0:00.45 pulseaudio 1298 gdm 20 0 98552 4340 3924 S 0.0 0.1 0:00.00 gnome-session-c 1306 gdm 20 0 248540 6024 5192 S 0.0 0.2 0:00.00 gnome-keyring-d 1312 gdm 20 0 496012 17136 14748 S 0.0 0.4 0:00.06 gnome-session-b 1321 gdm 20 0 2252776 157356 87328 S 0.0 3.9 0:03.83 gnome-shell 1346 gdm 20 0 244160 4696 4252 S 0.0 0.1 0:00.01 xdg-permission- 1367 gdm 20 0 396876 10356 8808 S 0.0 0.3 0:00.05 ibus-daemon 1375 gdm 20 0 174968 7992 7332 S 0.0 0.2 0:00.00 ibus-memconf 1378 gdm 20 0 209484 28560 19416 S 0.0 0.7 0:00.29 ibus-x11
top accepts either -u or -U , but not both at the same time.
$ top -u gdm -U gdm top: conflicting process selections (U/p/u)
$ pgrep -l -u gdm -U gdm 737 systemd 738 (sd-pam) 1260 dbus-daemon 1271 gdm-x-session 1273 Xorg 1282 gnome-session-b 1284 at-spi-bus-laun 1289 dbus-daemon 1294 pulseaudio 1298 gnome-session-c 1306 gnome-keyring-d 1312 gnome-session-b 1321 gnome-shell 1346 xdg-permission- 1367 ibus-daemon 1375 ibus-memconf 1378 ibus-x11 1382 ibus-portal 1405 at-spi2-registr 1415 gsd-wwan 1416 gsd-power 1417 gsd-wacom 1420 gsd-xsettings 1421 gsd-color 1430 gsd-keyboard 1434 gsd-rfkill 1436 gsd-a11y-settin 1442 gsd-media-keys 1448 gsd-smartcard 1453 gsd-sound 1461 gsd-print-notif 1484 gsd-printer 1487 ibus-engine-sim
Comment anonymously. Login not required.