How to show a running process name and its process ID (PID)
To find running processes by their name and PID , use the pgrep command. As the name implies, it is like the grep command, but for processes.
Examples using pgrep
To only see the PID (or PIDs), use pgrep followed by the process name.
# pgrep nginx
51055
60297
60298
If you want to see both the PID and process name, add the --list-name option.
# pgrep --list-name nginx
51055 nginx
60297 nginx
60298 nginx
This output can also be useful to confirm the right processes are targeted when using the pkill command.