pgrep pkill fulltext process name search

Adding the -f option to pgrep and pkill searches the whole command line, instead of the default first 15 characters. This is useful for example with chromium-browser that actually lists in ps as /usr/lib/chromium-browser/chromium-browser–too long for pgrep and pkill default to find.

pgrep -f chromium

works, while

pgrep chromium

does not work with default settings.

Make this change persistent by adding these lines to ~/.bash_aliases

alias pgrep="pgrep -f"
alias pkill="pkill -f"

Examples for Chromium:

  • find running process by name: pgrep chromium returns the PID (integer).
  • SIGTERM running process by name: pkill chromium