On 10/11/2012 02:49 AM, Chick Tower wrote:
> On 2012-10-10, Dan C <youmust...@lan.invalid> wrote:
>> On Wed, 10 Oct 2012 03:00:12 +0300, Timothy Madden wrote:
>>
>>> Hello
>>>
>>> Is there a way to allow my regular user to shut down the system with
>>> `shutdown` command ?
>>>
>>> Do I need to setuid the shutdown command ?
>>
>> Edit the file /etc/group (as root) and add your username to the 'power'
>> group. Then log out and back in, and it should work.
>
> I tried your suggestion, Dan, on Slackware 13.37, but it doesn't work
> for me, even with the username in /etc/shutdown.allow.
>
> Here's how to do it, Timothy. A line like the following goes in the
> "User privilege specification" section of /etc/sudoers:
>
> ctower amd2003 = NOPASSWD: /sbin/shutdown -h now
Yes, the power group din not work for me either:
bash-4.2$ grep power /etc/group
power:x:84:adrian,crina
bash-4.2$ id -Gn
adrian lp floppy audio video cdrom power scanner davfs2
bash-4.2$ cat /etc/shutdown.allow
adrian
bash-4.2$ /sbin/shutdown -a -h now
shutdown: you must be root to do that!
Usage: shutdown [-akrhPHfFnc] [-t sec] time [warning message]
-a: use /etc/shutdown.allow
-k: don't really shutdown, only warn.
-r: reboot after shutdown.
-h: halt after shutdown.
-P: halt action is to turn off power.
-H: halt action is to just halt.
-f: do a 'fast' reboot (skip fsck).
-F: Force fsck on reboot.
-n: do not go through "init" but go down real fast.
-c: cancel a running shutdown.
-t secs: delay between warning and kill signal.
** the "time" argument is mandatory! (try "now") **
Using sudo worked as expected, but there is no need for the
/etc/shutdown.allow file, because `shutdown` is running as root now.
Thank you,
Timothy Madden