I was unsuccessful in replacing the /etc/sudoers
file with a fresh new file and changing its permission to root:wheel
and 0440
.
Finally I had to go to Recovery Mode (restart → ⌘ CommandR)
- Mount Macintosh HD through Disk Utility
- Go to Terminal through Utilities
cd /Macintosh HD/private/etc
- Edit
sudoers
file to correct the mistakes. - Save and change permissions if needed.
sudoers
file needsroot:wheel
. If its not,sudo
won't be run.chown root:wheel sudoers
- I had also changed the permission topermissions with
chmod 0440 sudoers
since I initially removedsudoers
and created a fresh copy when I was logged in. - To change the permissions, run
chmod 0440 sudoers