Difference between revisions of "Allow users to shutdown"

From ArchWiki
Jump to: navigation, search
m (general headings)
Line 2: Line 2:
 
{{i18n|Allow Users to Shutdown}}
 
{{i18n|Allow Users to Shutdown}}
  
== The first way: sudo ==
+
== Using sudo ==
 
First install sudo:
 
First install sudo:
 
  # pacman -S sudo
 
  # pacman -S sudo
Line 18: Line 18:
 
  alias halt="sudo halt"
 
  alias halt="sudo halt"
  
==The Modern Way: PolicyKit==
+
==Using policykit==
 
Start your X session by prepending {{Codeline|ck-launch-session}} to your session-start line in {{Filename|~/.xinitrc}}
 
Start your X session by prepending {{Codeline|ck-launch-session}} to your session-start line in {{Filename|~/.xinitrc}}
 
  exec ck-launch-session startxfce4
 
  exec ck-launch-session startxfce4
Line 34: Line 34:
 
  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
  
==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 11:26, 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 policykit

Start your X session by prepending Template:Codeline to your session-start line in Template:Filename

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:
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
Note: Using dbus for suspend and hibernate requires upower.
  • 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

Using acpid

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