« Back to Processes: Frequently Asked Questions

How to show a running process name and its process ID (PID)

This article has last been updated at .

How to show a running process name and its process ID (PID)?

Use pgrep to search for running processes by their name and show their process ID.

pgrep -l PROCESSNAME

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

Feedback

Small picture of Michael Boelen

This article has been written by our Linux security expert Michael Boelen. With focus on creating high-quality articles and relevant examples, he wants to improve the field of Linux security. No more web full of copy-pasted blog posts.

Discovered outdated information or have a question? Share your thoughts. Thanks for your contribution!

Mastodon icon

Related articles

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