Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save macdet/12810cf9208c986bf286c8c5f15f7a96 to your computer and use it in GitHub Desktop.
Save macdet/12810cf9208c986bf286c8c5f15f7a96 to your computer and use it in GitHub Desktop.
Fix `sudoers` issue on macOS Catalina

Fix sudoers Issue on macOS Catalina

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.

How to Fix

  • 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 clicking Utilities > Terminal on menu.
  • In order to mount /etc as writable state, you need to disable SIP first by executing csrutil disable.
  • Reboot into single user mode. While rebooting press and hold Cmd+S key.
  • Mount /etc as writable state by executing mount -uw /System/Volumes/Data.
  • Make sure /etc/sudoers file and /etc/sudoers.d folder ownership is set to root. If not, execute chown root:wheel /etc/sudoers and chown 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment