restart computer without root from script

When I type

reboot

I get

reboot: Need to be root

P.S. I do not have sudo privileges and password

3 Answers

On Debian, you have to be a member of the powerdev group in order to shut the computer down as a regular user. I am not sure how this works in Ubuntu.

What you can do either way is to use the setuid bit in order to allow anyone to reboot the computer. Think about it, before you do this though. Maybe you can only set the setuid for the group of reboot and change the group of reboot to your own user group (or create a new power group by hand).

3

We don't know what Ubuntu you're using but to power off the computer try

dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop

and to restart

dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart

For a list of possible actions run

dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager org.freedesktop.DBus.Introspectable.Introspect

Try this command

systemctl reboot -i

To shutdown run this

systemctl poweroff -i

to hibernate, suspend, hybrid run

systemctl hibernate -i
systemctl suspend -i
systemctl hybrid-sleep -i

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like