If you messed up with editing sudoers
, this solution is for you. The solution is limited to restoring /etc/sudoers
file to the original state. It is easier to mess up your config such as saving wrong format, etc.
- Please reboot your macOS into recovery mode. While rebooting press and hold
Cmd+R
key. - After you completely reboot, you will see a dialog. You need to open
Terminal
by clickingUtilities > Terminal
on menu. - In order to mount
/etc
as writable state, you need to disable SIP first by executingcsrutil disable
. - Reboot into single user mode. While rebooting press and hold
Cmd+S
key. - Mount
/etc
as writable state by executingmount -uw /System/Volumes/Data
. - Make sure
/etc/sudoers
file and/etc/sudoers.d
folder ownership is set to root. If not, executechown root:wheel /etc/sudoers
andchown root:wheel /etc/sudoers.d
. - Make sure there is no
/etc/sudoers~
. If yes, please delete it. - Under
/etc/sudoers.d
directory, delete all files if needed. - Reboot into recovery mode to enable SIP. In terminal execute
csrutil enable
. - Finally reboot into normal mode.