I have some bash scripts which I manually run a lot and they need to run with sudo. I also don’t want to be prompted for any password. Here is the solution.
- Edit the /etc/sudoers:
$ sudo vi /etc/sudoers
- Add a new entry at the last (USERNAME is your account name).
# User privilege specification root ALL=(ALL:ALL) ALL # Members of the admin group may gain root privileges %admin ALL=(ALL) ALL # Allow members of group sudo to execute any command %sudo ALL=(ALL:ALL) ALL USERNAME ALL=(ALL:ALL) NOPASSWD:ALL # See sudoers(5) for more information on "#include" directives: #includedir /etc/sudoers.d
- Restart the sudo service.
$ sudo service sudo restart
- Logout then login again. You won’t be prompted for the password anymore.