# About sudo's NOPASSWD?



## sw2wolf (Apr 22, 2012)

I have ever posted this question before. That post had been flagged "SOLVED" which *I* think so before. However, it still has not been solved.


```
>cat [FILE]/usr/local/etc/sudoers[/FILE] | grep shutdown
Cmnd_Alias HALT=[FILE]/sbin/shutdown[/FILE] -p now
Cmnd_Alias REBOOT=[FILE]/sbin/shutdown[/FILE] -r now

>cat [FILE]/usr/local/etc/sudoers[/FILE] | grep NOPASSWD
%wheel ALL=NOPASSWD: HALT,REBOOT
```

The result is reboot does not need root's password which is ok. But halt still needs the root's password.

Sincerely!


----------



## DutchDaemon (Apr 22, 2012)

Try:


```
%wheel ALL=(root) NOPASSWD: HALT, REBOOT
```


----------



## sw2wolf (Apr 23, 2012)

DutchDaemon said:
			
		

> Try:
> 
> ```
> %wheel ALL=(root) NOPASSWD: HALT, REBOOT
> ```



Tt still doesnot work.


----------



## iddqd (Apr 23, 2012)

This might not be what you're looking for but adding your user to the operator group will allow you to execute /sbin/shutdown (along with a few other things) without using su (or sudo) to elevate your permissions.


----------



## sw2wolf (Apr 23, 2012)

iddqd said:
			
		

> This might not be what you're looking for but adding your user to the operator group will allow you to execute /sbin/shutdown (along with a few other things) without using su (or sudo) to elevate your permissions.




```
>id sw2wolf
uid=1001(sw2wolf) gid=1001(sw2wolf) groups=1001(sw2wolf),0(wheel),5([color="Red"]operator[/color]),920(vboxusers)
```

I have been in operator now.


----------



## phoenix (Apr 24, 2012)

Sigh.

What is the full sudo command that you are typing?  And what is the output of that command?


----------



## sw2wolf (Apr 24, 2012)

phoenix said:
			
		

> Sigh.
> What is the full sudo command that you are typing?  And what is the output of that command?


The command is:

`sudo /sbin/shutdown -p now`
`sudo /sbin/shutdown -r now`

No special output, it just needs me to enter the root's password which *I* do not want.


----------



## Kiiski (Apr 25, 2012)

Hi

 Sure you are editing sudoers file with `visudo`?

This kind of line should work (at least worked for me):


```
%wheel ALL=(ALL) NOPASSWD: /sbin/shutdown -p now, /sbin/shutdown -r now
```

And command to shutdown:

`sudo /sbin/shutdown -p now`

Similar for halt should work


----------

