In this tutorial, I will show how to kill all running processes launched by a user at once
With the help of few command chain, you can kill running process of desired "user" in LINUX
Commands like : ps, grep , awk, sudo, kill, pgrep, pkill, killall
First method
The first method is to feed kill command with a list of process IDs generated by ps command.
$ ps -ef | grep amit | awk '{ print $2 }' | sudo xargs kill -9
Second Method
A more convenient way to look up processes based on user name is to use pgrep.
$ pgrep -u amit | sudo xargs kill -9
Third Method
pkill can streamlines the whole process of looking up processes by user, and sending them signals. A default signal sent by pkill is SIGTERM. Using pkill, you can kill all processes by owner easily.
$ sudo pkill -u amit
Four Method
killall is very similar to pkill in terms of killing processes by user name.
$ sudo killall -u amit