Mac下终端sudo命令错误的解决:sudo: effective uid is not 0, is sudo installed setuid root?

Mac  下终端sudo命令错误的解决:sudo: effective uid is not 0, is sudo installed setuid root?


前几天sudo命令出现过一些其他的小问题,在Google的帮助下解决后这几天又出现了新的错误(标题所示),查过很多资料都是linux下的解决方案,mac下不适用,甚至后来还联系了苹果的电话客服寻求技术咨询结果跟我说不提供这种服务。


OS X 10.10 Yosemite 系统下可以在磁盘工具下使用修复磁盘权限进行解决,而OS X Ei Capitan 系统下已经取消了这个功能,所以究竟应该怎么解决呢,在多方面搜索之后发现了如下解决方法:

来源:http://superuser.com/questions/965923/lost-access-to-sudo-on-mac-want-to-regain-access

First use pkgutil to list the installer information for sudo.

pkgutil --file-info /usr/bin/sudo

Note the mode which is the permissions in octal notation for the file.

Shutdown your computer and then start the computer holding down the command key and the "s" key. You are booting the computer into single user mode.  (关机重启并一直长按 command + S 键,登录后即可进入单用户模式的命令行系统)

At the prompt force check the file system with the command

/sbin/fsck -fy

then mount the file system read write

/sbin/mount -uw /

Now change the permissions on sudo

chmod 4511 /usr/bin/sudo

Then reboot the computer

reboot

(第一个命令用时可能较多,请等待其执行完成后再输入新的命令)


重启进入正常系统后通常问题就解决了,但是部分用户可能会在开机后出现这种情况:

sudo: can't open /etc/sudoers: Permission denied
sudo: no valid sudoers sources found, quitting
这时你需要重复之前的那个操作,但是需要将倒数第二个命令替换为如下命令  (注意将地址替换为你报错的位置)
chmod a+x /etc/sudoers

重启之后测试发现问题已修复~~~~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值