Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

The following command signs me out (do not run this command):

kill -9 -1

I don't understand why.

Can someone explain this to me?

share|improve this question

3 Answers 3

up vote 71 down vote accepted

The syntax is kill SIGNAL PID.

The -9 option specifies that the SIGKILL signal should be sent (immediately terminate the target process(es), and specifying the PID -1 is shorthand for "all processes except itself and init".

Since you don't use sudo (and presumably don't have root permissions), this immediately kills all processes you have permission to kill - your entire session, hence logging you out.

share|improve this answer
9  
And note, if you run this command with sudo like sudo kill -9 -1 then the computer will restart –  Anwar Shah Sep 13 '12 at 14:02
    
Will it really restart? It seems like it would just crash. –  user606723 Sep 13 '12 at 18:14
    
@user606723 the init process will not exit, and can decide what (if anything) to do about all the other processes having exited. –  Random832 Sep 13 '12 at 19:09
3  
@Anwar it will not necessarily restart, it will drop you to running just init, which may or may not then spawn a shell or bring back up other services. –  mikebabcock Sep 13 '12 at 21:10

You are giving -1 as the process id: from the kill man-page:

 A  PID of -1 is special; it indicates all processes except the
 kill process itself and init.
share|improve this answer

try

man kill

to get an explanation of the kill command..

it says:

A PID of -1 is special; it indicates all processes except the kill process itself and init.

and

EXAMPLES

kill -9 -1

 Kill all processes you can kill.

I hope you understand why your computer will log you out, when you end all processes. You quitted everything.

Hope this helps.

share|improve this answer
18  
+1 for pointing to man. "Teach a fish how to man and you feed him for a lifetime." (Pun intended :-)) –  m000 Sep 13 '12 at 16:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.