How to kill all processes of a specific user

2016-02-14 | #solution, #ubuntu

Sometimes you may get the task of killing all left over processes of a specific user in Linux, for example to remove leftover processes of www-data after stopping an apache or nginx. This can be easily done with the following command:

kill `ps aux | grep www-data | awk '{print $2}'`

Add "-9" to force the action. Add more greps to be more precise. And be sure to be root, otherwise this won't do anything.