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
    Commented Aug 7, 2014 at 14:35

2 Answers 2

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .