4

My /etc/sudoers

josh ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart servicename.service

running systemctl restart servicename.service still asks for password. Does anyone have any ideas?

Running command: locate systemctl shows it located here: /usr/bin/systemctl

Josh
  • 125

1 Answers1

6

Just being in the /etc/sudoers file doesn't give you automatic root privileges all the time, as you seem to believe. You must preface the commands you wish to run as root with "sudo", like sudo systemctl restart servicename.service. Without the sudo, systemctl runs as your unprivileged $USER, and you are prompted for your password. Reread man sudo sudoers.

waltinator
  • 37,856