What does pgrep do?
pgrep is a command-line utility that allows you to find the process IDs of a running program based on given criteria. It can be a full or partial process name, a user running the process, or other attributes.
What does pidof do?
pidof command is used to find out the process IDs of a specific running program. It is basically an identification number that is automatically assigned to each process when it is created.
How do you become a pidof?
You can use pidof utility to find the process id’s (PIDs) by name. Please note that the pidof command only works on Linux based system, Unix user either try ps command or pgrep command to find the pid of a running program.
What does Pidof return?
pidof returns 0 when at least one running program matches with the requested name. Otherwise, the exit code is 1 . This can be useful when writing shell scripts. For example, if you have two running programs with the same name located in two different directories pidof will show PIDs of both running programs.
How are process IDs listed in pidof and pgrep?
The pidof and pgrep commands provide listings of process IDs (PIDs) for process names that you provide as arguments. This post shows how to use these commands and illustrates the differences between them with a series of examples.
What does pgrep look for in a process?
Because pgrep acts more like grep. It looks for processes that contain the string that is provided as an argument, not just those that match the process name exactly. In the command below, you can see more details on the processes that the above command selected:
How to get the PID of a process?
Using this command, you can get the PID of a process by typing “pidof” and specifying the process name. For example: If you were to run the ps command without arguments, you will get a list of the processes that you’re running in your current shell.