Linux - Allow User to Execute SUDO Without Password

As we know, if we want to execute something and act as administrator in linux (sudo) we need to input password.

But for some of developers (including me), it is annoying, so to handle that password, we can bypass the password.

In this case, I'd like to restart nginx without me having to enter the password, these are the steps :

  1. Edit /etc/sudoers
sudo nano /etc/sudoers
  1. Add customization

add this line at the bottom of the file

username ALL = NOPASSWD: /usr/sbin/service nginx restart
  1. restart your nginx

And finally testing time, execute:

sudo service nginx restart