Finds the process ID (PID) of a running program by name.
The pidof command is used to find the process ID (PID) of a running program. It is particularly useful in scripts for managing processes by their names rather than manually looking up PIDs.
pidof [options] [program_name]
-s: Return only a single PID.
-c: Only return PIDs with the same root directory.
-x: Also return PIDs of shells running the named scripts.
-o: Omit the specified process ID.
Program Name: Specifies the name of the process to search for.
pidof nginx
13312 5371
pidof crond
1509
pidof init
1