add pgrep into processes.md
This commit is contained in:
parent
96122eb0e9
commit
e796211d6f
85
processes.md
85
processes.md
@ -185,6 +185,64 @@ ps -eo pid,pcpu,pmem,args --sort -pcpu,pmem | head -10
|
||||
58902 0.8 1.3 /usr/lib/firefox-esr/firefox-esr -contentproc -childID 170 -isForBrowser -prefsLen 41310 -prefMapSize 222095 -jsInitLen 277276 -parentBuildID 20230214011352 -appDir /usr/lib/firefox-esr/browser 26789 true tab
|
||||
```
|
||||
|
||||
## Ricercare un processo
|
||||
|
||||
Come il comando grep è utilizzato per trovare stringhe da file ed output, il comando `pgrep` fa lo stesso per i processi.
|
||||
|
||||
La sintassi è molto semplice
|
||||
|
||||
```bash
|
||||
pgrep -i -u username process_name
|
||||
```
|
||||
dove `-i` attiva l'opzione **case-insensitive**.
|
||||
|
||||
### Ottenere il numero di processi di un utente
|
||||
|
||||
Per conoscere il numero di processi utilizzati da un utente specifico, utilizzare l'opzione `-c`:
|
||||
|
||||
```bash
|
||||
pgrep -cu davide
|
||||
|
||||
112
|
||||
```
|
||||
Ad esempio:
|
||||
|
||||
```bash
|
||||
> pgrep -u davide -l
|
||||
|
||||
1400 systemd
|
||||
1401 (sd-pam)
|
||||
1417 pipewire
|
||||
1418 wireplumber
|
||||
1419 pipewire-pulse
|
||||
1420 dbus-daemon
|
||||
1430 kwalletd5
|
||||
1431 startplasma-x11
|
||||
```
|
||||
Per trovare quale comando ha avviato il processo in questione basta digitare
|
||||
|
||||
```bash
|
||||
pgrep -u username -a
|
||||
|
||||
|
||||
> pgrep -u davide -a
|
||||
|
||||
1400 /lib/systemd/systemd --user
|
||||
1401 (sd-pam)
|
||||
1417 /usr/bin/pipewire
|
||||
1418 /usr/bin/wireplumber
|
||||
1419 /usr/bin/pipewire-pulse
|
||||
1420 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
|
||||
1430 /usr/bin/kwalletd5 --pam-login 7 8
|
||||
1431 /usr/bin/startplasma-x11
|
||||
```
|
||||
|
||||
### Elencare i processi per nome e PID
|
||||
|
||||
```bash
|
||||
pgrep -u username -l
|
||||
```
|
||||
|
||||
## Uccidere un processo
|
||||
|
||||
### Tramite PID
|
||||
@ -207,33 +265,8 @@ sudo pkill -9 top
|
||||
sudo killall -9 top
|
||||
```
|
||||
|
||||
|
||||
## Collegamenti
|
||||
|
||||
- [https://www.howtogeek.com/448271/how-to-use-the-ps-command-to-monitor-linux-processes/](https://www.howtogeek.com/448271/how-to-use-the-ps-command-to-monitor-linux-processes/)
|
||||
- [https://www.howtogeek.com/413213/how-to-kill-processes-from-the-linux-terminal/](https://www.howtogeek.com/413213/how-to-kill-processes-from-the-linux-terminal/)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
- [https://linuxhandbook.com/pgrep/](https://linuxhandbook.com/pgrep/)
|
||||
|
Loading…
x
Reference in New Issue
Block a user