Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

If more than one person is logged in on my computer, Ubuntu requires super user authentication when shutting down the computer. How can I make it so that any user can shutdown the computer without being asked for a password?

share|improve this question
2  
+1 I suspect entering a password to shutdown annoys many users on a home based PC. –  Richard Holloway Aug 6 '10 at 14:05
4  
If you shut down a computer while others are logged in, what happens to their open windows? Their open documents? I think anything that doesn't autosave is simply lost. This is worth considering. –  Torben Gundtofte-Bruun Feb 16 '11 at 15:24
    
"Ubuntu requires super user authentication when shutting down the computer", in Ubuntu 11.10 it doesn't ask for superuser authorisation, when shutdown using menu, it only works as logout and brings to Login page, like in this question: askubuntu.com/q/64073/11995, i'm interested how to configure Ubuntu to ask me for a superuser password? –  Mikl Dec 22 '11 at 21:34
add comment

9 Answers

up vote 22 down vote accepted

You do not need a workaround, just change the policy to allow you to shut down without authenticating as admin for shutdown and reboot when multiple users are logged in.

Edit the file /usr/share/polkit-1/actions/org.freedesktop.consolekit.policy using your favorite text editor. You will need root permissions.

Change the section relating to shutdown when others are logged in from

  <action id="org.freedesktop.consolekit.system.stop-multiple-users">
    <description>Stop the system when multiple users are logged in</description>
    <message>System policy prevents stopping the system when other users are logged in</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>auth_admin_keep</allow_active>
    </defaults>
  </action>

to

  <action id="org.freedesktop.consolekit.system.stop-multiple-users">
    <description>Stop the system when multiple users are logged in</description>
    <message>System policy prevents stopping the system when other users are logged in</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>yes</allow_active>
    </defaults>
  </action>

and the section relating to rebooting when others are logged in from

  <action id="org.freedesktop.consolekit.system.restart-multiple-users">
    <description>Restart the system when multiple users are logged in</description>
    <message>System policy prevents restarting the system when other users are logged in</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>auth_admin_keep</allow_active>
    </defaults>
  </action>

to

  <action id="org.freedesktop.consolekit.system.restart-multiple-users">
    <description>Restart the system when multiple users are logged in</description>
    <message>System policy prevents restarting the system when other users are logged in</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>yes</allow_active>
    </defaults>
  </action>

And that will allow you shutdown and reboot the PC when multiple users are logged in. Whether you want to do that is a different question.

share|improve this answer
1  
Here is a link with more on policykit : hal.freedesktop.org/docs/PolicyKit/polkit-conf.html –  Richard Holloway Aug 6 '10 at 14:07
    
This is to address being asked a password when shutting down the system from with Gnome. –  Richard Holloway Aug 6 '10 at 14:29
1  
Excellent! <15 chars> –  Alvin Row Aug 6 '10 at 17:07
3  
Won't your changes be wiped out whenever polkit is reinstalled or upgraded? –  Ryan Thompson Aug 6 '10 at 18:08
1  
@Ryan, according to wiki.ubuntu.com/SecurityTeam/PolicyKitPermissions/12.04 you could write a .pkla file inside /etc/polkit-1/localauthority, but I'm not sure about its syntax :) (some info here wiki.archlinux.org/index.php/PolicyKit#Authorities) –  Joril Oct 10 '12 at 16:01
show 3 more comments

There is a better way. If you have dbus-send installed, you can shutdown via dbus without the need to escalate to root privileges.

I can't remember the page where the documentation is, but one Archlinux user figured this out.

Shutdown:

dbus-send --system --print-reply --dest=org.freedesktop.Hal \
          /org/freedesktop/Hal/devices/computer \
          org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown

Reboot:

dbus-send --system --print-reply --dest=org.freedesktop.Hal \
          /org/freedesktop/Hal/devices/computer \
          org.freedesktop.Hal.Device.SystemPowerManagement.Reboot

Suspend:

dbus-send --system --print-reply --dest=org.freedesktop.Hal \
          /org/freedesktop/Hal/devices/computer \
          org.freedesktop.Hal.Device.SystemPowerManagement.Suspend int32:1

Hibernate:

dbus-send --system --print-reply --dest=org.freedesktop.Hal \
          /org/freedesktop/Hal/devices/computer \
          org.freedesktop.Hal.Device.SystemPowerManagement.Hibernate

Regards.

share|improve this answer
    
Wow that is... hacky. Awesome, yet hacky... –  jathanism Aug 6 '10 at 18:46
1  
Shutdown and Reboot seems doesn't work anymore in 11.10 –  Mikl Dec 18 '11 at 0:45
    
@Mikl try install hal (sudo apt-get install hal) –  Epeli Jul 15 '12 at 20:14
add comment

Richard Holloway's answer is not actually the way PolickKit authorisations are meant to be granted. The files installed under /usr/share/polkit-1/actions are not meant to be modified. Instead, you should modify the authorities under /etc/polkit-1/localauthority/50-local.d.

Here's how you do it for this question:

Create a file named /etc/polkit-1/localauthority/50-local.d/all_all_users_to_shutdown.pkla and edit it using sudoedit to look like this:

[Allow all users to shutdown]
Identity=unix-user:*
Action=org.freedesktop.consolekit.system.stop-multiple-users
AllowInactive=no
AllowActive=yes

Then create another file in the same directory (using any name you like ending with .pkla, for example, allow_all_users_to_restart.pkla), and fill it with these contents:

[Allow all users to restart]
Identity=unix-user:*
Action=org.freedesktop.consolekit.system.restart-multiple-users
AllowInactive=no
AllowActive=yes

References:

share|improve this answer
add comment

HAL seems to be now depcrecated and not installed in latest Ubuntu releases.

You must use ConsoleKit and UPower dbus services to manage power state

Shutdown:

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:

dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Hibernate

Thanks to Arch Linux forums.

This works for now in Precise and Quantal, but don't know for how long since the Freedesktop focus seems to be shifted from ConsoleKit to systemd. Don't know whether Canonical cares...

share|improve this answer
add comment

There is no way to circumvent the prompt for a superuser password when rebooting while other users are logged in short of opening a terminal window and issuing the reboot command as root:

sudo reboot

Even still, if not configured to bypass password prompting for your user account, sudo will also prompt you for your password.

Don't worry, these are GOOD things. Rebooting should be rare and a simple admin password prompt saves accidentally hosing yourself!

share|improve this answer
    
You can also edit visudo and make your user not prompt for password when typing sudo. –  Da1T Mar 4 '13 at 19:25
add comment

I believe this is only an issue when doing it through the command line.

If so here is a link that can help with your problem.

share|improve this answer
    
No, there is a popup window that asks for the admin password if there is another user logged in when you shut it down. Using the gui. –  Alvin Row Aug 5 '10 at 16:41
    
Thanks, I was looking for this –  Suhaib Sep 9 '12 at 0:06
add comment

Add halt and/or reboot into sudoers file assigned to the group/user you wish to allow to perform this task. That way you can still control who can shutdown, but without giving them full root access to the machine..

http://linux.byexamples.com/archives/315/how-to-shutdown-and-reboot-without-sudo-password/

share|improve this answer
add comment

This SU question might solve your problem.

share|improve this answer
    
This post was downvoted. Could whoever did this explain why? –  Seamus May 1 '12 at 15:49
1  
I did not down-vote yours. I think somebody did that because your link is showing us how to do that in the command line. While the asker is trying to solve the problem when shuting down from the GUI . Thanks for the link though. I was looking for it. –  Suhaib Sep 9 '12 at 0:09
add comment

Apparently, you are able to shut down without root from the GUI because gdm runs as root. Gnome tells gdm to shut down, and gdm does it.

You could do something similar with a script. I'm not sure how handy you are with BASH, but I believe one could write a script that runs as root and, when it receives a certain signal, runs the shutdown command.

Keep in mind that this may pose a security problem.

share|improve this answer
    
I think the problem he's likely to be encountering is the prompt that appears advising that others are still logged in, and requiring a sudo password to enable the shut-down/restart. –  David Thomas Aug 5 '10 at 19:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.