I use Monterey macOS v12.3.
Do you know how can I find the /etc
folder from the cd /Macintosh/ HD
?
I corrupted my sudoers
and I want to modify it from single-user mode, but I am not able to reach the path.
I tried the following looking for /etc
.
cd /Macintosh/ HD/System/Volumes/Data
cd /Macintosh/ HD/System/private
I read this topic, but there was no clue how to reach it: What's /System/Volumes/Data?
Below is the text taken from the currently closed question asked at Stack Overflow.
Title: I corrupted my sudoers file on MAC- how to modify from it from single user mode?
By mistake, I corrupted my sudoers
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 a MacBook Pro (16-inch, 2021) with macOS 12.3.
I rebooted with single user mode, and opened the Terminal, but I am not able to reach the directory to modify the file.
This log below is from the normal Terminal macOS, 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.
/Macintosh/ HD
should be/Macintosh\ HD
. Is this what you entered in a Terminal application window or just when entered your question? – David Anderson Mar 27 '22 at 07:46sudo
. – Gordon Davisson Mar 27 '22 at 09:58sudoers
with BBEdit. I was able withhosts
, but notsudoers
. I had to add user write access tosudoers
, then I could. However, the OP can not do this because he can not usesudo
. I was following the instructions given here. – David Anderson Mar 27 '22 at 11:31visudo
?visudo
is the command you should always use to editsudoers
specifically because it checks for syntax errors before replacing the old files and avoids bricking your system... – GACy20 Mar 28 '22 at 14:30