0

I want to give permission to a user to do shutdown command without password. Shutdown command need root privileges. If I give NOPASSWD in /etc/sudoers, the user can do all command that need root privileges without entering password. I want the user just has shutdown command permission without password, not other commands.

My exact goal is to do shutdown automatically after finished downloading a huge file. So, the user can do this:

wget *download link* || shutdown -hP now

I read somewhere that sudo can only remember password for about 15 minutes. So, if I do

sudo wget *download link* || shutdown -hP now

or

wget *download link* || sudo shutdown -hP now

and downloading process take more than 15 minutes, it will asking for password when I'm not around.

So, How do I add a command permission to specific user to do it without password?

0

1 Answer 1

1

From https://help.ubuntu.com/community/Sudoers:

Try adding the following to /etc/sudoers with <username> filled in appropriately:

Cmnd_Alias SHUTDOWN_CMDS = /sbin/poweroff, /sbin/halt, /sbin/reboot, /sbin/shutdown
<username> ALL=(ALL) NOPASSWD: SHUTDOWN_CMDS

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