From the “I always need this but never remember how to do it” file – How to kill a Linux process from the command line:
ps -A | grep processname | cut -c0-5 | xargs kill
This gets a listing of the process in question from ps -A that looks like this:
17468 ? 00:00:00 processname
and cuts the first five characters to get the process id and passes that straight to kill.
For extra crispiness, use kill -9.
Update: As my fellow readers have pointed out – the killall command already does this. So, don’t write your own and don’t listen to me, just use killall processname
However, if you’re looking to kill only certain processes, and not all processes of the same executable, you can modify the command like this for a more generic matcher patter:
ps -aux | grep process pattern | cut -c10-15 | xargs kill
tags: linux
