My sudo command not working [closed]

▼魔方 西西 提交于 2019-12-22 06:37:44

问题


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:

  1. Open the Script Editor utility.
  2. If a new (blank) script window doesn't open automatically, choose File menu > New (or press Command-N) to open one.
  3. Enter the following script:

    do shell script "chown root:wheel /etc/sudoers; chmod 440 /etc/sudoers; chmod -N /etc/sudoers" with administrator privileges
    
  4. Choose 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.

  5. Choose Script menu > Run (or press Command-R, or click the Run button in the toolbar).
  6. Enter your admin password when prompted.


来源:https://stackoverflow.com/questions/13197232/my-sudo-command-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!