pkill
(like pgrep
which uses the same interface, initially a Solaris command, now found on many other unix-likes including Linux (procps
package)) is to kill processes based on their name.
pkill regexp
kills (sends the SIGTERM
signal) to all the processes whose name¹ matches the given regular expression.
So here pkill node
would kill all the processes whose name contains node
. Use pkill -x node
(-x
like in grep
/pgrep
for exact match) to kill processes whose name is exactly node
.
To kill based on pid², it's just kill
(a command built in most shells so it can also be used on shell jobs, but also as a stand-alone utility).
If kill 6806
(short for kill -s TERM 6806
) fails, you can as a last-resort try kill -s KILL 6806
which would terminate it non-gracefully.
¹ process name being a notion that varies a bit depending on the OS. On Linux, it's generally up to the first 15 bytes of the base name of the file that the process (or its closest ancestor) executed, though a process may change it to any arbitrary (but not longer than 15 bytes) value. See also pkill -f
to match on the argument list.
² kill
can also kill based on process group id. kill -- -123
sends the SIGTERM signal to all the processes whose process group id is 123. When using the job specification for the kill
builtin of POSIX shells (as in kill %spec
), kill
generally also sends signals to a process group.
pkill
is to kill processes based on their name. To kill based on pid, it's justkill
. Ifkill 6806
(short forkill -s TERM 6806
) fails, you can trykill -s KILL 6806
which would terminate it non-gracefully. – Stéphane Chazelas Mar 20 '18 at 15:51