Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Sometimes I notice that the process Python hung up. Then I'll kill it via the Activity Monitor and everything is fine.

I'd like to kill that process in the Terminal instead. However, looking up the PID seems kind of unecessary because there's only one process by the name Python.

Is it possible to kill a process by its unique name?

share|improve this question
up vote 26 down vote accepted

You should be able to run the command sudo killall Python.

You need to run as root because Python belongs to root, not the user.

share|improve this answer
I did that: No matching processes belonging to you were found – gentmatt Mar 3 '12 at 18:05
The Python process doesn't belong to your user. Try it as root instead: sudo killall Python. – HenningJ Mar 3 '12 at 18:09
@HenningJ Sudo worked for some reason. I just saw that the process does belong to me. I could kill the process without sudo when I killed it using it's PID. Why? – gentmatt Mar 3 '12 at 18:18
I'm thinking it's because using a PID isn't user/root specific, whereas a process name is. I'll edit this answer to reflect sudo. – Matt Love Mar 3 '12 at 18:23
This also worked for multiple identically named processes, nice – chrismarx May 31 '14 at 14:25
sudo killall -s SIGINT "process name"

If you can't be a sudo because it will ask for password and I feel you don't want that in a script. pkill come for rescue :)

pkill -9 "process name"
share|improve this answer
Thanks for saving my life – taha027 Mar 7 at 11:51

You can kill Applications by using Activity, being the GUI solution. That would be a simple "force quit". However, that doesn't always work out for different reasons in some situations!

The command-line solution as mentioned in the comment above holds a lot more options for the user. sudo killall Python or if it is a running program-process sudo killall /Applications/ forces the the process to quit as well.

You can also force a process to quit, using its assigned PID. In the case of Activity it would be kill 25794 or kill -9 25794

enter image description here

Some more details:

The kill program in Terminal simply force quits a program, as though by remote control. (It even works when you SSH into your Mac from a remote location. Follow the kill command with the process ID number (short PID) of the program you want to terminate.

Unless you also use sudo, you can kill only programs you “own”—those running under your account. (The operating system itself—root—is always running programs of its own, and it’s technically possible that other people, dialing in from the road, are running programs of their own even while you’re using the Mac!)

The -9 flag is a “non-catchable, non-ignorable kill.” In other words, it’s an industrial-strength assassin that accepts no pleas for mercy from the program you’re killing.

share|improve this answer

Although it does use PID, I find the following to be pretty efficient:

ps aux | grep "String or name of process"

This line returns a host of information about the matching process(es), and you can kill or whatever from there.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.