0

I want to shutdown my Linux system using a script from GUI:

shutdown.sh
#!/bin/bash
init 0

This script asks me a question.

I need a shutdown script without asking any question.

Note that my GUI login is root user.

1
  • 1
    Would it be possible for you to show the output when running this script?
    – ryekayo
    Aug 7 '14 at 14:35
2

Since you are already root, then you can call

shutdown -h now

and the system will go down right away with no confirmation needed.

0

For doing init 0 you will need root rights. Using DBUS to send the shutdown signal circumvents this:

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

Put this line in your script and it should work.

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.