Kill a Process by Process Name from Ubuntu Command Line
There are a number of ways to kill a process if you know the name of the process. Here’s a couple different ways you can accomplish this. We are going to assume that the process we are trying to kill is named irssi
kill $(pgrep irssi)
killall -v irssi
pkill irssi
kill `ps -ef | grep irssi | grep -v grep | awk ‘{print $2}’`
These techniques can be useful in shell scripts, where you wouldn’t know the process ID and would need to restart or kill a process.
The Geek is the founder of How-To Geek and a geek enthusiast. This article was written on 09/25/06 and tagged with: Shell Scripts, SysAdmin, Ubuntu
Daily Email Updates
You can get our how-to articles in your inbox each day for free. Just enter your name and email below:
| Similar Articles | Featured Wiki Articles |
| Latest Software Reviews | Quick Linux Tips |
| Geek Arcade | Popular Forum Threads |


ps -ef | grep irssi | grep -v grep | xargs kill
would work too
I just use this: killall (program name). Works fine for me.
Thanks Nicholas. It is working
Thank you! My wine was crashing, and my gnome-system-monitor couldn’t close it (under Ubuntu 8.10). I could close it with
killall -v wineserver
My CPU was quickly raising temperature, so thank you for this helpful simple short guide!
Perfect! Just what i was looking for.
Thanks!
Thanks for helping this newbie out.