« Back to Processes: Frequently Asked Questions

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.

Other questions related to Processes

Related articles

Like to learn more? Here is a list of articles within the same category or having similar tags.

Feedback

Is the described answer not working or incorrect, got another tip or question? Share your thoughts!