It depends on your Display Manager! (i.e. KDM, GDM)
Please bear in mind your DM runs as root! (it needs root privileges in order to run your session process as the user you log in)
When you click shutdown in KDE or GNOME, your DE sends a signal to your DM to power off or restart after the session has terminated. Then, your DE tells every program to end and once all other process has terminated (or expired a timeout), the last process of your DE -- the session process -- terminates.
The session process is the first process started in an X11 session. When it's killed or it terminates, the session terminates. Have you ever seen that xterm when running X without DE? That is a session process. This process is called kdeinit
in KDE and gnome-session
in GNOME.
Once the session has terminated, control is returned to your DM (which has been waiting for the X process to end), and it checks what the DE told him to do. If it told it to power off or restart, it will do that. In other case, it will just start a new login screen in X.
This is also related with problems you may have had in the past, with some DE not being able to power off or restart, just to log out, when used in combination with some other DMs.
In any case, this is not so bad documented. GDM has a manual page "gdm-control(1)" of a command which allows you to tell it to shut down just like I told before (gdm-control
). KDM has excellent documentation too and has a similar (a little more complex) utility named kdmctl
.
Shutdown and restart is possible without PolicyKit, but PolicyKit serves many purposes needed on nowadays systems like mounting disks without being root, suspend or hibernate the computer. And it neither is bad documented!
Check out this if you want to know more about what is PolicyKit and how does it work: http://www.freedesktop.org/software/polkit/docs/latest/polkit.8.html
I have the same issue, I have no idea what is, to temporarily resolve this I created an alias in .bashrc.
alias poweroff='su -c "'"systemctl poweroff"'"'
alias restart='su -c "'"systemctl reboot"'"'
Best Answer
This thread had many suggestions that look like good leads for you to follow up with.
Things to try
idea #1 - systemdIf your system uses systemd try using this:
idea #2 - blacklist kernel module mei_me idea #3 - interrogate journalctl boot messagesTake a look at the
idea #4 - Add kernel parameter acpi=forcejournalctl
for feedback on what's causing the system to reboot.Try adding the following to your kernel's boot parameters. These can be appended to the end of your kernel's line in
idea #5 - Try a different power supply (larger rated) idea #6 - disable WOL (Wake On LAN) idea #7 - bug in kernel with xhci module/etc/grub2.cfg
.Source Bug 66171 - [PATCH]Poweroff doesn't work, it just reboots