Whenever I try any sudo
command whatsoever in terminal, I get the following error message:
sudo: /etc/sudoers is owned by uid 503, should be 0
sudo: no valid sudoers sources found, quitting
I have tried logging into single user mode and typing in the following commands:
mount -uw
chown /private/etc/sudoers 0
After typing in the chown ownership line, I get an error message saying “illegal username”.
Other things I have tried:
- Reinstalling the OS X (El Capitan)
- Disabling System Integrity Protection (SIP).
- Calling Apple Care who say that
sudo
commands have been disabled in El Capitan. - Logging in under Single User mode and typing in the following code:
chown root:wheel /private/etc/sudoers
This produced the error message “Operation Not Permitted” in my Standard, Admin, and Root accounts.
The error message “Read-Only File System” came up when I logged in in Single User Mode.
FYI
When I run ls -la /private/etc/sudoers
in Terminal, I get the following:
-rw-r-----@ 1 MY-ADMIN-USERNAME staff 67 18 Feb 14:03 /private/etc/sudoers
Note I’ve replaced my actual admin username with “MY-ADMIN-USERNAME” just so you know what’s showing.
I need sudo
commands to work for a range of reasons, one of which is to get CrashPlan to work.
My hardware is a 2010 iMac, 3.2GHZ, 16GB Ram and 500GB SSD which was installed about a year ago.
These problems have only come up with El Capitan. I didn’t have them in the past with Yosemite.
Looking around online, I can see the many people have had similar issues but the resolutions unfortunately have not worked for me.
Best Answer
Try to repair your sudoers file from Recovery Mode:
cd "/Volumes/main_volume_name/private/etc"
. Replacemain_volume_name
by the real main volume's name (checkdiskutil list
), keep any spaces and upper/lower case characters as they are. If you use quotation marks like in the command here you don't have to escape spaces with a\
chmod 440 sudoers
chown root:wheel sudoers
Check the file with
cat sudoers
. The default sudoers file should look like this:Since your sudoers file is very small (67 bytes) you are probably missing some or all content. You may have to add/replace at least the lines without a prepending "#":
and
with:
The file should finally contain at least the following content:
The file requires a trailing empty line! (Please don't simply copy the above because the last line here doesn't contain a new line but a zero-width space)
Boot to your main volume and log-in as an admin
sudo xattr -c /etc/sudoers
to remove the (false) attributes.sudo visudo /etc/sudoers
by editing in the above default sudoers' contentFinally the file info should reveal the following:
It hasn't to be compressed though and the date will obviously be different.