Link to home
Start Free TrialLog in
Avatar of beer9
beer9Flag for India

asked on

Usage of negative pid in kill command

I have seen in few example where the negative pid was used with 'kill' command to kill all process of a user. Could someone please let me know how it can be done?


Will kill all your processes, including the shell you're on/your ssh connection 
kill -9 -1 -1

to kill all d process including login shell:
kill -9 0 

Open in new window


Could someone please let me know how does it works? using above example how can I kill all the process of a particular uid/user?
ASKER CERTIFIED SOLUTION
Avatar of sakman
sakman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Let run some commands so you can get the picture

echo $$    # get your current shell pid , say 1234
pstree -pl -H 1234   # show the process tree, which 1234 branch highlighted.

say

bash (1234) ----pstree( 1239)
                   |--java (1235)
                   |--perl (1236)

So, the current process goup is root as 1234 and include child processes 1235, 1236, and 1239.

When you issue
kill -9 0
  it kills processes  1239, 1235, 1236 and 1234.