Difference between revisions of "Allow users to shutdown"

From ArchWiki
Jump to: navigation, search
m (general headings)
m (linking to consolekit)
Line 18: Line 18:
 
  alias halt="sudo halt"
 
  alias halt="sudo halt"
  
==Using policykit==
+
==Using consolekit==
Start your X session by prepending {{Codeline|ck-launch-session}} to your session-start line in {{Filename|~/.xinitrc}}
+
See [[ConsoleKit]] for usage with display managers. You can also use dbus for power operations:
exec ck-launch-session startxfce4
+
Note that if you are using a display manager (KDM, GDM..) [[PolicyKit]]/ConsoleKit will be utilized automatically.
+
 
+
You can now use dbus for power operations:
+
 
*shut down:
 
*shut down:
 
  dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop
 
  dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop
 
*restart:
 
*restart:
 
  dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart
 
  dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart
{{Note|Using dbus for suspend and hibernate requires upower.}}
 
 
*suspend:
 
*suspend:
 
  dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
 
  dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
 
*hibernate (suspend to disk):
 
*hibernate (suspend to disk):
 
  dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Hibernate
 
  dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Hibernate
 +
{{Note|Using dbus for suspend and hibernate requires {{Package Official|upower}}.}}
  
 
==Using acpid==
 
==Using acpid==
 
[[acpid]] can be used to allow anyone with physical access to cleanly shut down the computer by using this power button.
 
[[acpid]] can be used to allow anyone with physical access to cleanly shut down the computer by using this power button.

Revision as of 15:08, 14 July 2011

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.


Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어


External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Using sudo

First install sudo:

# pacman -S sudo

Then, as root, add the following to the end of Template:Filename using the Template:Codeline command. Substitute Template:Codeline for your username and Template:Codeline for the machine's hostname.

user hostname=NOPASSWD: /sbin/shutdown -h now,/sbin/reboot

Now your user can shutdown with Template:Codeline, and reboot with Template:Codeline. Users wishing to power down a system can also use Template:Codeline or Template:Codeline.

For convenience, you can add these aliases to your user's Template:Filename (or to Template:Filename for system-wide settings):

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

Using consolekit

See ConsoleKit for usage with display managers. You can also use dbus for power operations:

  • shut down:
dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop
  • restart:
dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart
  • suspend:
dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
  • hibernate (suspend to disk):
dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Hibernate
Note: Using dbus for suspend and hibernate requires Template:Package Official.

Using acpid

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