How do I disable user password request to shut down from retropie?

I am a newb to Ubuntu/Linux. I am running Ubuntu 16.04.3 LTS with retropie. Whenever I try to shut down the system from retropie it always asks for a password and I have to plug in a keyboard and enter the password.

How do I disable the password request so I can shut down easily from retropie?

A simple step by step would be appreciated!


Solution 1:

Edit your box's sudoers file. In a terminal run sudo visudo. visudo does a good job of limiting the damage that can be done by manual edits. Adding the following lines, replacing bob with the correct username. Running the above command with sudo requires the current user's password.

Cmnd_Alias SHUTDOWN_CMDS = /sbin/poweroff, /sbin/halt, /sbin/reboot
bob ALL=(ALL) NOPASSWD: SHUTDOWN_CMDS

If your system is not connected to the Internet in anyway, an alteritive is to change the line sudo ALL=(ALL) ALL to sudo ALL=(ALL) NOPASSWD: ALL. If connected to the internet this is risky.

The sudoers file alters sudo permissions to allow a specified user or group to run specific commands. In this case bob can run various shutdown commands without a password.

The /etc/sudoers file controls who can run what commands as what users on what machines and can also control special things such as whether you need a password for particular commands. The file is composed of aliases (basically variables) and user specifications (which control who can run what).
- Ubuntu Community Wiki - Sudoers.