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:
[code language=”bash”]$ sudo vi /etc/sudoers[/code]
- Add a new entry at the last (USERNAME is your account name).
[code language=”text” firstline=”18″ highlight=”26″]
# 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:
- Restart the sudo service.
[code language=”bash”]$ sudo service sudo restart[/code]
- Logout then login again. You won’t be prompted for the password anymore.