How to kill specific processes in Linux

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

How to kill specific process in Linux

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

How to kill specific process in Linux 02

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!

About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created DevopsRoles.com site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.