我的sudo命令不起作用 [英] My sudo command not working

查看:362
本文介绍了我的sudo命令不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台Mac 10.8.2山狮,当我尝试使用sudo命令时,我得到了:

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

我已经在Google各处搜索并尝试了几项尝试,但有一点解决了我的原始烫发问题,其中0440为0640或类似的东西,但是我明白了.任何帮助将不胜感激

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

推荐答案

最简单的方法是使用磁盘工具"的修复磁盘权限"功能.运行磁盘实用程序,在边栏中选择启动卷,选择第一个Sid"选项卡,然后单击修复磁盘权限".

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.

将来,请使用visudo命令编辑sudoers文件,以避免此类问题.

And in the future, use the visudo command to edit the sudoers file to avoid this sort of problem.

更新:El Capitain(10.11)已删除了修复磁盘权限"功能,因为(主要)它已由

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. 打开脚本编辑器实用程序.
  2. 如果没有自动打开新的(空白)脚本窗口,请选择文件"菜单>新建"(或按Command-N键)以打开一个窗口.
  3. 输入以下脚本:

  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

  • 选择脚本"菜单>编译"(或按Command-K,或单击工具栏中的编译"按钮).它应该给脚本着色以指示AppleScript语法.如果报告任何错误,请确保您正确复制了脚本.

  • 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.

    这篇关于我的sudo命令不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆