I am looking to migrate a Snoozer application I originally wrote in windows on AutoIt, which when it comes down to it is a Shutdown Snoozer.

I list faling asleep to a movie or show, but I wake up if my pc runs through the night. So I built an application which notifies you that there is a pending shutdown and you have 10 minutes to snooze this otherwise the PC shuts down. The application allows you to repeat this prompt for X times and on a Y interval.

My question is, in Ubuntu will I need sudo rights to shutdown. If so, how can I prevent the application from continually asking the user to authenticate as sudo in order to shutdown the system properly??

2 Answers
2

Yes, the user need to have sudo rights, but you can use NOPASSWD to skip password authentication anyway.

To allow a user to run specific commands, in this case, the shutdown command, edit the /etc/sudoers file, for example:

user ALL=/usr/bin/apt-get,/sbin/shutdown

A more detailed version which suits your requirement better (user can shut down using sudo shutdown -h now and reboot with sudo reboot. Users wishing to power down a system can also use poweroff or halt without password):