问题
I have a mac 10.8.2 mountain lion and when i try to use the sudo command i get this:
sudo: /private/etc/sudoers is owned by uid 501, should be 0
sudo: no valid sudoers sources found, quitting
I have searched google all over and tried a couple of things but one thing kinda fixed my orignal perm problem with 0440 being 0640 or something but i got this. Any help will be appreciated
回答1:
The easiest way to fix this is with Disk Utility's Repair Disk Permissions feature. Run Disk Utility, select your startup volume in the sidebar, select the First Sid tab, and click Repair Disk Permissions.
And in the future, use the visudo command to edit the sudoers file to avoid this sort of problem.
Update: the Repair Disk Permissions feature was removed in El Capitain (10.11), because it's (mostly) replaced by System Integrity Protection. If you need to fix the permissions on /etc/sudoers in 10.11 or later, you can do it from AppleScript:
- Open the Script Editor utility.
- If a new (blank) script window doesn't open automatically, choose File menu > New (or press Command-N) to open one.
Enter the following script:
do shell script "chown root:wheel /etc/sudoers; chmod 440 /etc/sudoers; chmod -N /etc/sudoers" with administrator privilegesChoose Script menu > Compile (or press Command-K, or click the Compile button in the toolbar). It should colorize the script to indicate the AppleScript syntax. If it reports any errors, make sure you copied the script correctly.
- Choose Script menu > Run (or press Command-R, or click the Run button in the toolbar).
- Enter your admin password when prompted.
来源:https://stackoverflow.com/questions/13197232/my-sudo-command-not-working