📅 2017-Feb-27 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ kill, pgrep, pkill, ps ⬩ 📚 Archive
pgrep and pkill are two useful commands that go well together. You can list processes using ps and kill them using kill. However, I find it easier to use pgrep and pkill when I want to find and kill a process.
$ pgrep --uid joe
$ pgrep -u joe
$ pgrep --uid joe --list-name
$ pgrep -u joe -l
$ pgrep --uid joe --list-full
$ pgrep -u joe -a
This is extremely useful because to find Python scripts or commandline arguments to a program that is running as a process.
$ pgrep foobar
$ pgrep -l foobar
$ pgrep -a foobar
pkill is used to send a signal to or kill processes by using a pattern that matches a process name or its command line. pkill takes many arguments that are similar to pgrep.
$ pkill foobar
$ pkill -f foobar
Tried with: Ubuntu 16.04