Difference between revisions of "Allow users to shutdown"

From ArchWiki
Jump to: navigation, search
(Using systemd-logind: rq)
m (Keep interlanguage in order.)
Line 1: Line 1:
 
[[Category:Security]]
 
[[Category:Security]]
 +
[[es:Allow Users to Shutdown]]
 
[[id:Allow Users to Shutdown]]
 
[[id:Allow Users to Shutdown]]
 
[[it:Allow Users to Shutdown]]
 
[[it:Allow Users to Shutdown]]
Line 6: Line 7:
 
[[uk:Allow Users to Shutdown]]
 
[[uk:Allow Users to Shutdown]]
 
[[zh-CN:Allow Users to Shutdown]]
 
[[zh-CN:Allow Users to Shutdown]]
[[es:Allow Users to Shutdown]]
 
 
== Using systemd-logind ==
 
== Using systemd-logind ==
  

Revision as of 12:04, 5 October 2012

Using systemd-logind

If you're using systemd, users with non-remote session can issue power-related commands. To keep these permissions, your session simply needs to stay on the same tty where the login happened. With a display manager, that will work out-of-the-box and startx -- vt$(fgconsole) can be used to have it work without one.

The suspend, poweroff and hibernate button presses and lid close events are also handled by logind (see man logind.conf.

Using sudo

First install sudo:

# pacman -S sudo

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: /sbin/shutdown -h now,/sbin/halt,/sbin/poweroff,/sbin/reboot

Now your user can shutdown with sudo shutdown -h now, and reboot with sudo reboot. Users wishing to power down a system can also use poweroff or 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 (or to /etc/bash.bashrc for system-wide settings):

alias reboot="sudo reboot"
alias poweroff="sudo poweroff"
alias halt="sudo halt"

Using consolekit

See ConsoleKit#Use dbus for power operations for usage instructions.

Using acpid

acpid can be used to allow anyone with physical access to cleanly shut down the computer by using this power button.