Configure password (less) sudo in Ubuntu 16.04
/etc/sudoers does not remove the password prompt for all sudo commands.
do Not change sudoers
Do not change sudoers if you want to use sudo with no password prompt on Ubuntu 14.04 and 16.04?
The line at the bottom of your sudoers file
#includedir /etc/sudoers.d is not a comment. It is an include that overwrites your sudoers change.
How to End Sudo Password Prompts in Ubuntu
You can either add a file (with visudo) to the /etc/sudoers.d directory or you can append to an existing file.
All Amazon EC2 cloud instances come without password prompts for the first user. If this applies to you – appending to the
/etc/sudoers.d/90-cloud-init-usersfile is an option. It pays though to start your own configuration.
Step 1 – Use visudo to create and edit
The visudo command opens up a new configuration file.
sudo visudo -f /etc/sudoers.d/custom-users
It is important
- to use visudo – it is safe with it and treacherous without
- that your filename has neither dots nor squigglies. So
my-users.confis a no-no!
- not to change sudoer (or sudoers.d) permissions – immediate lock out results
The visudo command presents you with an empty file.
Step 2 – Configure No
sudo Password Prompts
Never used the vi editor? – It does not matter – you just type in a comment line and the sudo configuration line.
# This configuration will silence password prompts when sudo is used # For documentation visit build business websites and search on sudoer <<username>> ALL=(ALL) NOPASSWD:ALL
Now we need to save the file.
Step 3 – Save and Exit Visudo
Hold down the
Ctrl-Key and press the letter
To confirm press shift and Y
Press Enter to agree to a temporary file. That’s it.
Step 4 – Verify no password prompts after sudo
It pays to start a new shell as the user specified – and test it with say
No password prompt! Well done – lights out and away you go.