SEARCH

How-To Geek

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.

Lowell Heddings, better known online as the How-To Geek, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on if you'd like.

  • Published 09/25/06

Comments (20)

  1. sven

    ps -ef | grep irssi | grep -v grep | xargs kill
    would work too

  2. Nicholas

    I just use this: killall (program name). Works fine for me.

  3. Mahmut

    Thanks Nicholas. It is working

  4. Kar.ma

    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!

  5. Matthew Glennon

    Perfect! Just what i was looking for.

    Thanks!

  6. tryntobegeek

    Thanks for helping this newbie out.

  7. sameer

    i am wondering whether a kill command can be piped ot not

    i tried the command
    ps | grep hbuild_topic | cut -c-6 | kill to kill all the process with the name hbuild_topic i wasnt able to kill the process

  8. Anotherone

    or ps aux | grep irssi | grep -v grep | awk ‘{print$2}’ | xargs kill -9

  9. Kevin

    Force Quit launcher in the panel works for me

  10. JR

    hi there. very new with ubuntu 10.xx. is there a gui app for forcing a program closed. I was looking for the “Force Quit Launcher” Kevin has posted but I’m unable to find it.

    Please advise,

    and take it easy on me. took 13 years to switch over.

    Regards;

    Justin

  11. liam

    @JR:

    Open up Keyboard Shortcuts
    (System->Preferences->Keyboard Shortcuts)

    Click Add, name it something like ‘Force Quit’; the command to use is xkill

    Then click on the command in the list and hold down CTRL+ALT+K: now, whenever you press CTRL+ALT+K, a little white cross will replace your cursor. and when you click on a window it will close.

  12. tsai

    I do the following when killall “process name” doesn’t work:

    1. type the command “ps aux” (brings up a list of processes by pid and name)
    2. right click and copy all from the terminal
    3. create a text file “vim aux.txt”
    4. press “i” for insert
    5. press shift-insert keys
    6. press escape key
    7. press / key and enter the process name you are looking for
    8. use the n key to find the next process with that name until you can’t find anymore
    9. write down the pids or type them in notes
    10. exit out of the txt file back to the command line
    11. kill “pid1″ “pid2″ “pid3″ and so on on the same line
    12. rm aux.txt (or whatever you named it.)

    This is much faster once you get used to it than it looks here. The advantage is that it gets all processes running under that name. Killall doesn’t always work. You don’t have to remember the other commands this way too.

    Love UNIX!

  13. jotr

    Nice! I like the “grep -v grep” part. :-)

  14. JMeds

    A little long for my tastes, but this worked the first time!

    kill `ps -ef | grep irssi | grep -v grep | awk ‘{print $2}’`

    Thanks for the suggestions.

  15. fernand

    my ubuntu 11.04 the flash will crush. what i shall i do

  16. hotfloppy

    I always use this command to kill any ‘naughty’ apps:

    # pgrep appName | xargs kill -9

  17. Aschkan

    hi all;

    Im actually a beginner in Ubuntu, here is a process named ‘exe’ whose status is ‘zombie’ :D
    how can I stop this process?! I should say that non of the commands above worked!
    other information about this process are:
    memory ‘N/A’ and waiting channel ‘do_exit’

    your attention would be appreciated :)

  18. jikay

    hey how to kill root password and dis able it forever??

  19. linuxguy

    i don’t know how to disable it forever, but i know how you can set it to what you want…open terminal and type sudo passwd, then it will ask you to enter it, then ask what you want the new root pass to be, then confirm it, and that should take care of it..hope that helps

  20. troguy

    Cheers! You’ve helped me fix a problem I’ve had for ages, being unable to stop a running gamesever

Get Free Articles in Your Inbox!

Join 134,000 newsletter readers

Email:

Go check your email!