Hi, this is Sandra Henry-Stocker, author of the “Unix as a Second Language” blog on NetworkWorld.
In this Linux tip, we’re going to look at the pidof and pgrep commands. Both help you to find the process IDs (PIDs) of running processes. All you have to do is enter the command followed by the name of the process you’re interested in.
For example, with pidof you can ask about systemd processes like this:
As you see, pidof found three systemd processes running on the system.
If you use pgrep instead of pidof, the list will also include processes that contain the specified string as part of the process name – so there are more of them. It also lists them in a vertical format and in numerical order.
The additional process IDs in this list are systemd-logind and other processes that are related to systemd, but have longer names.
That’s your Linux tip for pidof and pgrep.
If you have questions or would like to suggest a topic, please add a comment below. And don’t forget to subscribe to the IDG Tech(talk) channel on YouTube.
If you liked this video, please hit the like and share buttons. For more Linux tips, be sure to follow us on Facebook, YouTube and NetworkWorld.com.