The pidof
command in Linux is used to find the process ID (PID) of a program or command. Here are some examples of how to use the pidof
command:
- Find the PID of a specific process:
pidof process_name
where process_name
is the name of the process you want to find the PID of. For example, to find the PID of the ssh
service, you would use the following command:
pidof ssh
- Find the PID of multiple processes:
pidof process1 process2 process3
where process1
, process2
, and process3
are the names of the processes you want to find the PIDs of.
Note: The pidof
command will return the PID of the first instance of the process it finds. If you have multiple instances of the same process running, you can use the pgrep
command instead.
- Find the PID of a running process using
pgrep
:
pgrep process_name
where process_name
is the name of the process you want to find the PID of. For example, to find the PID of the ssh
service, you would use the following command:
pgrep ssh
This will return a list of all PIDs of the processes that match the name ssh
.