pgrep

>Usage

The pgrep command in Unix is used to search for processes currently running on the system based on specified criteria, such as process name, user, or group. It outputs the process IDs of matching processes.

>Synopsis

pgrep [-u | -l | -f | -c ...]

>Options

-u

Lists process IDs for processes owned by a specified user.

Example:

Dots

-zsh

> pgrep -u john


1032
2048

-l

Displays the process ID and the name of each matching process.

Example:

Dots

-zsh

> pgrep -l python


1032 python3
2048 python2

-f

Matches against the full command line rather than just the process name.

Example:

Dots

-zsh

> pgrep -f my_script.py


1032

-c

Counts the number of matching processes.

Note: This option is not supported on macOS; it is only valid on Linux.

Example:

Dots

-zsh

> pgrep -c python


2

>Quiz

Progress: Question ? out of 4

Question Title

Page written by Emily Pable