Friday, April 26, 2024
 Popular · Latest · Hot · Upcoming
7
rated 0 times [  7] [ 0]  / answers: 1 / hits: 23427  / 3 Years ago, mon, october 18, 2021, 6:46:12

I am using Ubuntu 11.04. I want to run a script which checks for a running process and shuts down the system when that process ends. To do this, the user requires shutdown access so that the script may be executed without requiring a password.



I referred to this page and added the text in my sudoers file. However, it's still asking me the password whenever I execute sudo shutdown -h now. Also, I get an error saying root privileges are required, when I execute shutdown without sudo.



My sudoers file looks something like this.



# Cmnd alias specification
Cmnd_Alias SHUTDOWN = /sbin/shutdown

# User privilege specification
root ALL=(ALL:ALL) ALL
myusername ALL = NOPASSWD: SHUTDOWN


How can I give permission to a user to execute the shutdown command without having to manually enter the password?



Thanks.


More From » 11.04

 Answers
4

You can shut down or restart using HAL or ConsoleKit which will not require you enter an username/password:



HAL (older Ubuntu versions):



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


ConsoleKit (newer Ubuntu versions, tested on Ubuntu 11.04):



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

[#44552] Tuesday, October 19, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
warrdel

Total Points: 356
Total Questions: 103
Total Answers: 118

Location: Bangladesh
Member since Sat, Jan 23, 2021
3 Years ago
;