Restart/Shutdown when running as non root user
Posted: Saturday 22 May 2021 8:21
hi all,
I'm running Domoticz 2021.1 on my Raspberry Pi Zero with DietPi OS (a very slimmed down Raspberry OS).
When DietPi installed Domoticz, it created a user called "domoticz", but by default he is not in the sudo group. So of course, he cannot shutdown or restart the system and you will see the following error when typing `sudo systemctl status domoticz.service` :
So what is the solution? You need to allow the user domoticz access to the shutdown command. For that, you need to edit the /etc/sudoers file with `sudo visudo` and add this line at end:
Hope this can help someone!
I'm running Domoticz 2021.1 on my Raspberry Pi Zero with DietPi OS (a very slimmed down Raspberry OS).
When DietPi installed Domoticz, it created a user called "domoticz", but by default he is not in the sudo group. So of course, he cannot shutdown or restart the system and you will see the following error when typing `sudo systemctl status domoticz.service` :
Code: Select all
May 22 08:06:31 DietPi domoticz[420]: #1) Respect the privacy of others.
May 22 08:06:31 DietPi domoticz[420]: #2) Think before you type.
May 22 08:06:31 DietPi domoticz[420]: #3) With great power comes great responsibility.
May 22 08:06:31 DietPi domoticz[420]: sudo: no tty present and no askpass program specified
May 22 08:06:31 DietPi sudo[632]: pam_unix(sudo:auth): conversation failed
May 22 08:06:31 DietPi sudo[632]: pam_unix(sudo:auth): auth could not identify password for [domoticz]
May 22 08:06:31 DietPi sudo[632]: domoticz : command not allowed ; TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/sbin/shutdown -r now
May 22 08:06:31 DietPi domoticz[420]: Error executing reboot command. returned: 256
May 22 08:06:31 DietPi domoticz[420]: domoticz: Error executing reboot command. returned: 256
May 22 08:06:31 DietPi domoticz[420]: 2021-05-22 08:06:31.496 Error: Error executing reboot command. returned: 256
Code: Select all
domoticz ALL= NOPASSWD: /usr/sbin/shutdown