June 09, 2008

How-To: Kill a Process Using the 'pidof' Command

If a process hangs and you want to easily kill it, type in a console:

kill -9 $(pidof process_name)

And replace process_name with a currently running process. For example, to kill Amarok you would issue the following:

kill -9 $(pidof amarokapp)

Or Banshee, as another example:

kill -9 $(pidof banshee)


kill -9 $(pidof banshee-1)

pidof is a command that finds the process ID (PID) of a given application. What is inside the ( and ) parenthesis is replaced with a certain PID, and the process which has that PID will be killed.

Updated: June 09, 2008 (Created: June 09, 2008)


Anonymous said...

isnt this the same as pgrep?

Dan Craciun said...

Yes. Just looked up the man page for pgrep and it looks like it has more available options than pidof. But both return the PID if used as 'pgrep app_name'.

Anonymous said...

(other anon)

isn't this the same as "killall -signal process" (e.g. killall -9 amarokapp)

Anonymous said...

Only that killall works different on some unix dialects. (in fact VERY different, as it does what the name implies)
The Ubuntu manual warns abot this. So kill -9 $(pidof xyzname) is much more universal.
BTW:Thanks for this!