Linux pidof Command Examples To Find PID of A Program/Command

htt‮ww//:sp‬w.lautturi.com
Linux pidof Command Examples To Find PID of A Program/Command

The pidof command is a Linux utility that can be used to find the process ID (PID) of a program or command. The pidof command takes a program name as an argument and prints the PID of the process that is running the program.

For example, to find the PID of the nginx program, you can use the following command:

$ pidof nginx

This will print the PID of the nginx process. If there are multiple instances of the nginx program running, the pidof command will print the PID of all instances.

You can use the -s option to print the PID of only the first instance of the program. For example:

$ pidof -s nginx

You can use the -x option to search for the program by its full path name. For example:

$ pidof -x /usr/sbin/nginx

You can also use the -o option to specify a PID to be excluded from the search. For example:

$ pidof -o 1234 nginx

This will print the PID of all nginx processes except for the process with PID 1234.

The pidof command is useful for finding the PID of a program or command that is running on the system. You can use the PID to perform various tasks, such as sending signals to the process or examining its status using the ps command.

Created Time:2017-10-30 10:17:42  Author:lautturi