4

I am using LXDE on Debian. When logged in LXDE as user, I can click on the logout icon in the menu and choose one of the options:

  • shutdown
  • reboot
  • logout
  • suspend

But when I type reboot or shutdown -r now in the terminal, that does not work.

How can I shutdown my system as the user from within the terminal? I need a command, which will be executed when my battery is critically low, so that my system can be shut down cleanly.

  • you need to add the right to your user to use the command poweroff or shutdown using visudo. – Kiwy Jan 16 '14 at 14:54
  • Can't the power management software do things like that? It should be running with sufficient privileges already. I know apcupsd can be made to do it, because I use it to do it :) – a CVn Jan 16 '14 at 14:56
  • When you have physical control over the system (it sits on your desk) and the reset button is within arms length, these security restrictions seem absurd. – ChuckCottrill Jan 16 '14 at 16:25
5

The command run when your computer is running low on battery should be configurable through your desktop environment's GUI. Just open the settings app of whatever you use and look at the power options, you should have something like (this is on Cinnamon):

enter image description here

To make your user able to run these commands without entering a password, run sudo visudo to edit /etc.sudoers and add these lines (assuming your user name is martin):

martin ALL=NOPASSWD:/usr/sbin/pm-suspend
martin ALL=NOPASSWD:/sbin/reboot
martin ALL=NOPASSWD:/sbin/shutdown

You can then run them with no password like so:

sudo reboot

Alternatively, and specifically for shutdown, you can add your user to /etc/shutdown.allow and then run shutdown -a but that one does not work for Debian.

  • But you can click on the menu item in your desktop environment, even if you aren't a sudoer. You could trigger the same mechanism from the command line. (D-Bus, but I don't know what message to send.) – Gilles Jan 16 '14 at 23:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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