One minute
pgrep & pkill
These two litte commands can make the life of an administrator much easier, but most admins aren’t even aware of their existence. pgrep
searches the process table and returns a list of PIDs matching the search pattern. Using the -fl
option, one can extend the search to the full argument list of the processes. This is equivalent to ps ax | grep
, but you don’t get the PID of its own command back as a search result! The well known options -v, -i
of grep
work as expected, as well as the options of ps
, like -t, -u, -g
. pkill
acts much like killall
, but with the power of pgrep
added to it. All in all these tools come in handy in shell-scripts or as a quicker alternative to ps ax | grep
.