Allow users to shutdown
To check if your session is active
$ loginctl show-session $XDG_SESSION_ID --property=Active
$ systemctl poweroff
The suspend, poweroff and hibernate button presses and lid close events are also handled by logind as described in ACPI events page.
Install , then, as root, add the following to the end of
/etc/sudoers using the
visudo command. Substitute user for your username and hostname for the machine's hostname.
user hostname =NOPASSWD: /usr/bin/systemctl poweroff,/usr/bin/systemctl halt,/usr/bin/systemctl reboot
Now your user can shutdown with
sudo systemctl poweroff, and reboot with
sudo systemctl reboot. Users wishing to power down a system can also use or
sudo systemctl halt. Use the
NOPASSWD: tag only if you do not want to be prompted for your password.
For convenience, you can add these aliases to your user's
~/.bashrc if you have it enabled (or to
/etc/bash.bashrc for system-wide settings):
alias reboot="sudo systemctl reboot" alias poweroff="sudo systemctl poweroff" alias halt="sudo systemctl halt"
acpid can be used to allow anyone with physical access to cleanly shut down the computer by using this power button.