Skip to content

pkill command on Linux (send signals)

The pkill command on Linux sends signals to processes on Linux. It works the same way as pgrep, and most of the options apply to both pkill and pgrep.

The sign can be entered numerically or by name:

# pkill -1 nginx

Or

# pkill -HUP nginx

Your common options are:

-signal, —signal signal name or number
Defines the signal to be sent to each corresponding process. The name of the numerical or symbolic sign may be used. (for pkill only.)

-c, —count
Suppress normal output; print a count of corresponding processes instead. When the count doesn’t match anything, for example, it returns zero, the command will return a value other than zero.

-d, —delimiter delimiter
Defines the string used to delimit each process ID in the output (by default, a new line). (pgrep only.)

-f, —full
Normally, the default is compared only with the process name. When -f is set, the full command line is used.

-l,
—list-name List the process name and process ID. (pgrep only.)

-a, —list-full
List the full command line as well as the process ID. (pgrep only.)

-n, —newest
Select only the newest (most recently started) of the matching processes.

-o, —oldest
Select only the oldest matching processes (started less recently).

-P, —parent ppid
Only match processes whose parent process ID is listed.

-t, —terminal terminal,…
Only match the processes whose control terminal is listed. The terminal name must be specified without the “/dev/” prefix.

-u, —euid euid
Only those matching processes whose effective user ID is listed. Numerical or symbolic value may be used.

- U, —uid,…
Only match processes whose real user ID is listed. Numerical or symbolic value may be used.

-v, —inverse
Deny the match. This option is generally used in the context of pgrep.

-w, —lightweight
Show all thread IDs instead of pids in the context of pgrep. In the context of pkill, this option is disabled.

-x, —exact
Only match processes whose names (or command line if -f is specified) match the pattern exactly.

-F, —pidfile
Read PID’s from the file. This option is perhaps more useful for pkill than pgrep.

Learn much more about Linux in our online course. You can register here. If you already have an account, or want to create one, just log in or create your user here.

Did you like it?

Share