This article will describe how to omit sudo password. This will enable scripts with sudo be automated.
Table of Contents
1 Enable wheel group in /etc/sudoers
Edit /etc/sudoers with visudo.
$ sudo visudo
Enable wheel group which is disabled by default.
diff -uprN /etc/sudoers{.org,} --- /etc/sudoers.org 2016-11-18 20:59:50.045948489 +0900 +++ /etc/sudoers 2016-11-18 21:00:26.525321111 +0900 @@ -76,7 +76,7 @@ root ALL=(ALL) ALL # %wheel ALL=(ALL) ALL ## Same thing without a password -# %wheel ALL=(ALL) NOPASSWD: ALL +%wheel ALL=(ALL) NOPASSWD: ALL ## Read drop-in files from /etc/sudoers.d ## (the '#' here does not indicate a comment)
2 Add user to wheel group
Add user to wheel group with gpasswd.
$ sudo gpasswd -a hiroom2 wheel