Linux – How to kill all processes with the same name

killlinuxprocessuser

I want to kill all processes with the same name that belong to a user,
for example:

$ps -u user_1
2345 myapp
2346 myapp
2347 myapp
2348 myapp2
2349 myapp

I want to kill all "myapp" processes that belong to "user_1", how can I do this?

Best Answer

You can use the pkill command.

pkill -u user_1 myapp

Note that myapp2 won't be killed as it has a different name.