Why does running `killall init` as user log me out

initkilllogout

On multiple computers running Ubuntu 14.XX, I ran the command "killall init" as user, and was immediately logged out. I could log back in again without a problem. Why is this? What's going on behind the scenes?

Best Answer

On newer Upstart systems, a session init process is started when you login using the GUI. Since Ubuntu uses Upstart, there's an init process for your session. Test it out using pstree -ps $$ in a terminal:

$ pstree -ps $$
init(1)───lightdm(1741)───lightdm(9511)───init(9526)───/usr/bin/termin(9570)─┬─gnome-pty-helpe(9734)                                                                                                                                                                                  
                                                                             └──zsh(7944)

So when you run killall init, you're not killing init PID 1 (because you don't have the privilege), but your session init, which would be PID 9526 in this example.

Since this init is the governing process for your GUI session, killing it kills your session and therefore you are logged out.

Related Question