It is common practice to use a sudo username instead of the root for security reasons. In some cases (like letting Ansible do it’s thing on a server), you will need to sudo without a password prompt.
- The file that contains all the sudoers is located at
/etc/sudoers. It is highly recommended to not edit this file directly. Instead, edit it with visudo, which will do some checks to make sure you won’t break your system. So:
- Find the section that says
#User privilege specification
- Add the following line below root, or edit your existing user:
username ALL=(ALL:ALL) NOPASSWD: ALL
You can save the file. If you are using Nano, you can hit Ctrl+O and Enter to save it.
Finally test it with a command, like
sudo apt-get update. You should not get a password prompt.