How do I kill a process by its name in Linux?

3

1

I have a process with the name bla, and I want to kill it by its name.

When I run ps aux | grep "bla", I get 2 entries:

  • process bla and
  • blablablab

How do I filter it out?

farka

Posted 2010-06-29T09:44:49.717

Reputation:

Please be more specific and provide the example or the actual terminal scrrenshot. – None – 2010-06-29T09:51:38.097

Answers

12

killall bla

to force it:

killall -9 bla

Leom Burke

Posted 2010-06-29T09:44:49.717

Reputation: 381

5

Take a look at pkill, if available.

YuppieNetworking

Posted 2010-06-29T09:44:49.717

Reputation: 266

1+1. man pkill also mentions the pgrep. The tools are part of the same package as top and ps and should be available on pretty much all Linux systems. (Solaris has them too). killall and pidof are not so portable. – Dummy00001 – 2010-06-29T10:47:58.817

pkill is the most flexible by far. Kills by user, parent process, terminal… – Tobu – 2010-06-29T10:57:52.133

0

You can use the PID of the process to kill it.

Check out man pages for command kill.

The exact option would be kill -9 <pid>

Praveen S

Posted 2010-06-29T09:44:49.717

Reputation: 111

Do you shut down your computer by holding the power button for X amount of seconds also? Because kill -9 is equally stupid. Please read http://speculation.org/garrick/kill-9.html

– None – 2010-06-29T09:51:14.773

this way you are killing the process by his pid but by this name. – TheHippo – 2010-06-29T09:55:45.757

0

While the killing question has been well answered, you asked how can you avoid getting the process "blabla" when you wanted "bla". What you want to do is add -w:

ps aux | grep -w "bla"

Philip Kearns

Posted 2010-06-29T09:44:49.717

Reputation: 825

This does not kill it by its name. – superuser0 – 2013-04-08T19:10:35.470

Not intended to kill, I just noticed no one had answered his other question, namely how to find "bla" without finding "blabla". – Philip Kearns – 2013-04-08T22:28:30.177