fbpx pkill Command in Linux: Terminate Processes by Name | Certificação Linux

pkill Command in Linux: Terminate Processes by Name

📅 01/01/2019 ⏱ 2 min ✍️ Uira Ribeiro
Linuxcommands
pkill Command in Linux: Terminate Processes by Name
Exam Pass App — mais de 7.000 questões LPI, offline, em 5 idiomas, disponível no Android e na App Store
Available on
Google Play
Available on
App Store

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

The signal can be specified numerically or by its name:

# pkill -1 nginx

Or

# pkill -HUP nginx

Its common options are:

-signal, --signal name or number
Specifies the signal to be sent to each matching process. The numeric or symbolic signal name can be used. (pkill only.)

-c, --count
Suppress normal output; instead, print a count of matching processes. When the count does not match anything, e.g. returns zero, the command will return a non-zero value.

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

-f, --full
Normally, the pattern is matched only against the process name. When -f is set, the full command line is used.

-l, --list-name
List the process name and the 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 (least recently started) of the matching processes.

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

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

-u, --euid euid
Only match processes whose effective user ID is listed. The numeric or symbolic value can be used.

-U, --uid,…
Only match processes whose real user ID is listed. The numeric or symbolic value can be used.

-v, --inverse
Negates the match. This option is typically used in the context of pgrep.

-w, --lightweight
Shows 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) exactly match the pattern.

-F, --pidfile
Read PIDs from file. This option may be more useful for pkill than pgrep.

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

Like it? Share

Uira Ribeiro

Prof. Uirá Ribeiro

Chair do Board do Linux Professional Institute

After years of watching professionals waste hours on simple tasks because they didn't know the right Linux tools, I decided to teach.
Today I'm the author of most of LPI's official Learning Materials and mentor to over 14,000 certified students.

See my full story →

That was just one piece. The course teaches the whole path — from your first command to exam day.

Certificação Linux — a plataforma líder em certificações Linux no Brasil
WhatsApp