How to kill processes run by a User on Linux
If you are a DBA, there are situations where you want to kill all processes belonging to a specific user, for example because the user is being removed or the user is forking malicious processes. It will take long time to kill individual processes of the user one by one manually. In this post I will show you how to kill all the process IDs at a time launched by a user.
Here I use a command that kills all the processes owned by Linux user say "applfprd".
To generate the process IDs, we use ps command
$ ps -ef | grep applfprd | awk {'print $2'}
Now we have to kill the process IDs which are generated above
$ ps -ef | grep applfprd | awk {'print $2'} | xargs kill -9
(or)
$ sudo pkill -u applfprd
(or)
$ pgrep -u applfprd | sudo xargs kill -9
(or)
$ sudo killall -u applfprd
No comments:
Post a Comment