Killing an Application with Terminal

From Mac Guides

Jump to: navigation, search

In most cases, you can force quit an application without using the Terminal. However, in some cases using the Terminal is the only possible option or is the easiest.

For example, you could be trying to connect to your computer from another computer, but VNC may not be working. In this case, the VNC server program could be the culprit, and you may want to kill it in the command line.

To do this, follow these steps:

  1. If on a remote computer, open an SSH connection to your machine (note: This requires SSH access to be enabled), otherwise just open the Terminal.
  2. At the command line, type: top -u and press enter
  3. Look for the program name, and then look to the left. You will see a number next to it. Jot the number down, that is the PID, or Process ID.
  4. Type q
  5. Type sudo kill PID (where PID is the number you jotted down). It will ask for your password, enter it.
  6. If the application is not responding to the kill command, sudo kill -9 PID will force the application to quit.
  7. To reopen the program, type open /Applications/[name].app, where name is the application's name. If the application is not in the Applications folder, you'll need to specify a different path. You can, of course, double click the application in the Finder in the traditional manner.

Instead of the kill command, it is possible to use the killall command, such as "killall iTunes" or "killall Safari". See "man killall" for more info.

Hint: You can also use the tab button to fill in a blank when manually typing names out, long or short. E.g. typing open /Applications, you can simply type open /App and press tab, it will fill out the rest.