So I was trying to grant user name shutdown as root permission. I created a shutdown group and add my username using:
groupadd shutdown usermod -A shutdown annguyen
Afterward, I logged in a as root using su - then visudo. Commented out these lines:
Defaults targetpw ALL ALL=(ALL) ALL
I will talk about what happens if I uncomment them.
I then add the line %shutdown ALL=(ALL) NOPASSWD:/sbin/shutdown
Ok, so here's the behavior.
When I call up xterm, then typed
sudo /sbin/shutdown -h 17:00 it returns
user annguyen is not in the sudoer file. This incident will be reported. I have checked again and again, I'm positive that I am in the shutdown group and the line allowing the group to use shutdown is added.
However, when I log into myself again using
su annguyen and try
sudo /sbin/shutdown ... again it works. However I am effectively logged in twice as my own username. I know because when I type exit it doesn't close xterm but return me to the parents shell, also logged in as me. So basically, the child shell logged in as annguyen can call sudo shutdown, but the parent shell, also logged in as annguyen, can't. Why is that?
Not sure if I miss anything. Ultimately, what I wanted is that if I invoke
sudo /sbin/shutdown/ it will ask me for annguyen's password while everything else is for root.
Is this possible?