Mac Terminal: Avoid password I‘m trying to make a siri-shortcut which let you shutdown your mac.

https://www.icloud.com/shortcuts/7c625a68308740d9b84cc0eaa9353055

The command is:

sudo shutdown -h now


But when I run this command I must enter my password can I do something to run this command without the password?



Sorry for bad english
It could be configured to make sudo skip password prompt for specific command with /etc/sudoers.

# modify /etc/sudoers with visudo
# never open it directly with an editor
sudo visudo


Append the following conf into the file,

Cmnd_Alias SHUTDOWN_NOW = /sbin/shutdown -h now
%admin ALL=(root) NOPASSWD: SHUTDOWN_NOW


Done.