How to kill a proccess?

Discussion in 'Command Line' started by carbon333, Feb 16, 2012.

  1. animaguy

    animaguy New Member

    Messages:
    53
    Likes Received:
    1
    Trophy Points:
    0
    thanks to all on this thread.

    Office Libre froze on me for the first time.

    I was working on a complex data base and as part of a reformatting technique, I copy and pasted a worksheet to another worksheet for backup and the whole thing froze.


    Eventually I was able to close and start all over again from where I last saved.

    If it happens again I will remember this thread and try some of the commands.
  2. Hector

    Hector New Member

    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Interesting. I usually run skill $name.
  3. KenJackson

    KenJackson Active Member

    Messages:
    129
    Likes Received:
    28
    Trophy Points:
    28
    I never heard of skill before. I was going to congratulate you on the find, but grief! Look how unflattering the man page is:

  4. Hector

    Hector New Member

    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    What can I say? It works fairly well for my needs. :p
  5. Bill

    Bill New Member

    Messages:
    127
    Likes Received:
    5
    Trophy Points:
    0
    If it is a graphical process, like Libreoffice, you can use xkill. After you type xkill in a terminal, you then just click on the program that you want to close. Works great for me and is much easier than trying to find the process ID.
  6. nixsavy

    nixsavy Member

    Messages:
    65
    Likes Received:
    17
    Trophy Points:
    8
    You can also use fuser command to kill all processes. For example you want to kill apache2, find full running command with top as below

    Code:
    #top -c
    Output will as

    Code:
    1312 root      18   0 73516 2724 1252 S  0.0  0.3   0:00.02 /usr/sbin/apache2 -k start
     1313 www-data  18   0 73516 2048  564 S  0.0  0.2   0:00.00 /usr/sbin/apache2 -k start
    
    and run fuser with -k option and command as below

    Code:
    #fuser -k /usr/sbin/apache2
    and all processes will kill and output will as below of this command.

    Means these process ids has been killed.
  7. ryanvade

    ryanvade Administrator Staff Member Staff Writer

    Messages:
    1,260
    Likes Received:
    428
    Trophy Points:
    83
  8. bashcommando

    bashcommando Active Member

    Messages:
    212
    Likes Received:
    43
    Trophy Points:
    28
    kill `pidof <Process Name>`
  9. centos_fan

    centos_fan New Member

    Messages:
    10
    Likes Received:
    9
    Trophy Points:
    3
    ps and then kill is enough and most convenent if you don't care about data missing.
  10. bashcommando

    bashcommando Active Member

    Messages:
    212
    Likes Received:
    43
    Trophy Points:
    28
    EXACTLY! What was that again?
  11. MikeyD

    MikeyD Active Member

    Messages:
    232
    Likes Received:
    112
    Trophy Points:
    43
    It should be stressed that SIGKILL aka -9 aka -KILL should be used as a last resort!

    Kill can send a number of signals to a process to terminate. Sending a signal to the process first is usually a better option (as long as the program was well written and knows how to handle termination signals) as it lets the process clean itself up and potentially save progress before exiting. SIGKILL on the other hand doesn't send a signal to the process itself but to the kernel telling the kernel to immediately halt/kill/murder/destroy the given process. Sometimes this is the only option, but its generally not the cleanest.

    I generally run ps to get the PID (comptuers work with PIDs you should be doing the same)
    run kill $PID (sends SIGTERM signal by default if no flag is specified)

    If it is still not killed i'll then run kill -9 or kill -KILL to SIGKILL the process.
  12. Jefff

    Jefff New Member

    Messages:
    5
    Likes Received:
    1
    Trophy Points:
    1
    I know this is the command line section, but if you are on a desktop, you can always press CTRL-ESC
  13. jerz4lunch

    jerz4lunch New Member

    Messages:
    19
    Likes Received:
    6
    Trophy Points:
    3
    To kill the current shell process, type this in a shell.
    Code:
    kill -9 $$
    $$ is a environment variable for the current shell's Process ID.

Share This Page