Kill Processes Using Wildcards with pkill in Mac OS X

Oct 18, 2012 - 2 Comments


For anyone who uses the command line regularly, a new tool called pkill makes killing processes significantly easier in modern releases of Mac OS and Mac OS X. Improving on the standard kill command, pkill easily supports wildcards, making it easy to terminate all processes belonging to a match or even a specific user.

Using pkill to Kill Processes on Mac OS

At it’s most basic function, pkill can be used as follows:

pkill ApplicationName

For example, killing all processes belonging to “Safari”, including Safari Web Content processes, would be just a matter of typing:

pkill Safari

Killing Processes with pkill and Wildcards

But pkill is perhaps best used with uid flags and wildcards, for example you can kill all processes that start with the letter “C” using the following:

pkill C*

Processes belonging to a single user can also be terminated easily with the -U flag and additional details:

pkill -U username ProcessName

For example, you could kill every process belonging to user Will with the following;

sudo pkill -u Will *

Assuming the specified user is logged in, all apps running by that user will be killed. However, the user will not be logged out and core system processes pertaining to that user will remain intact.

Review the manual page for pkill for more uses and flags, and remember that average Mac users will be better served managing tasks with Activity Monitor instead. pkill is not available to Mac OS or OS X prior to Mountain Lion.


Related articles:

Posted by: William Pearson in Command Line, Mac OS, Tips & Tricks


» Comments RSS Feed

  1. Corey says:


    Are you saying that if you want to pkill all processes with the name C you have to give it the command pkill ‘C*’ ?

  2. Marc says:

    Your wildcard examples suffer from a flaw… the shell will attempt to expand the wildcards before pkill sees them. take this example: pkill C*

    It will not work if the current working directory has any file that starts with a capital C. The shell will expand the wildcard expression and pkill will be given the names of the files in your current working directory that start with C, not the expression ‘C*’.

Leave a Reply


Shop on and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks


iPhone / iPad



Shop on Amazon to help support this site