You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

I corrupted my sudoers file - how to modify from it from single user mode

Hello


by mistake, I corrupted my sudoer file, i modified it, and mis-spelled a word that corrupted the file

I wrote NOPASSED instead of NOPASSWD.

in the meantime, I am not able to edit it any more.


I am using MacBook Pro (16-inch, 2021), OS 12.3


I rebooted with single view mode, and opened the terminal, but i wan not able to reach that directory to modify the file. any help?




##### This log below is from the normal terminal OS , not from the single user mode #####


oahmed@oahmed-mac /etc % ls -l | grep sudo

-r--r-----  1 root wheel   257 26 Feb 02:05 sudo_lecture

-r--r-----  1 root wheel  1573 2 Feb 12:18 sudoers

drwxr-xr-x  2 root wheel   64 26 Feb 02:05 sudoers.d


oahmed@oahmed-mac /etc % more sudoers

sudoers: Permission denied


oahmed@oahmed-mac /etc % sudo vi sudoers

/etc/sudoers:56:34: syntax error

%admin ALL = (ALL) NOPASSED: ALL

                  ^

Password:

Sorry, user oahmed is not allowed to execute '/usr/bin/vi sudoers' as root on oahmed-mac.




Posted on Mar 25, 2022 6:34 PM

Reply

Similar questions

1 reply

Mar 31, 2022 7:00 PM in response to Ladanow

Ladanow wrote:

Hello

by mistake, I corrupted my sudoer file, i modified it, and mis-spelled a word that corrupted the file
I wrote NOPASSED instead of NOPASSWD.
in the meantime, I am not able to edit it any more.

I am using MacBook Pro (16-inch, 2021), OS 12.3

I rebooted with single view mode, and opened the terminal, but i wan not able to reach that directory to modify the file. any help?



##### This log below is from the normal terminal OS , not from the single user mode #####

oahmed@oahmed-mac /etc % ls -l | grep sudo
-r--r-----  1 root wheel   257 26 Feb 02:05 sudo_lecture
-r--r-----  1 root wheel  1573 2 Feb 12:18 sudoers
drwxr-xr-x  2 root wheel   64 26 Feb 02:05 sudoers.d

oahmed@oahmed-mac /etc % more sudoers
sudoers: Permission denied

oahmed@oahmed-mac /etc % sudo vi sudoers
/etc/sudoers:56:34: syntax error
%admin ALL = (ALL) NOPASSED: ALL
                  ^
Password:
Sorry, user oahmed is not allowed to execute '/usr/bin/vi sudoers' as root on oahmed-mac.




I'll see if I can get this moved for more eyes


Mac OS X Technologies - Apple Community


I corrupted my sudoers file - how to modify from it from single user mode

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.