I want to shutdown my OS without typing the sudo password.
Create a new file in /etc/sudoers.d/ directory.
Note that, any files under this directory is sourced in the /etc/sudoers file. And, always use visudo to edit sudoers files, as it safeguards you from getting locked out due to bad sudo configurations.
$ sudo visudo -f /etc/sudoers.d/nosudopassword; # any filename works, just a matter of choice.
ALL ALL= (root) NOPASSWD: /sbin/shutdown,/usr/local/bin/someOtherScript
Note: Always use absolute path of the commands/scripts. Find the absolute path using
$ which shutdown;
Now, you can type $ sudo shutdown; and your OS will turn off right away.
Cmnd_Alias MYSCRIPT = /usr/local/bin/someOtherScript
%adm ALL = (ALL) MYSCRIPT