In this tutorial, How to kill specific Processes in Linux? I use “ps -ef” command to display PID of the Processes. Linux the essential for DevOps Roles.
kill specific processes in Linux
For example, kill all PID of the browser Firefox. But not kill line “grep –color=auto firefox” as the picture below
Use ps command with “-ef” option the display PID of browser Firefox.
[huupv@huupv devopsroles]$ ps -ef | grep firefox
The only display PID of Firefox as command below
[huupv@huupv devopsroles]$ ps -ef | grep firefox | grep -v "grep" | awk '{print $2}'
The screen output terminal as below
Using kill command to kill all Processes for Firefox as command line below
[huupv@huupv devopsroles]$ sudo kill -9 $(ps -ef | grep firefox | grep -v "grep" | awk '{print $2}')
Conclusion
Thought the article, How to kill specific processes in Linux as above. I hope will this your helpful. Thank you for reading the DevopsRoles page!