mac sudo: /etc/sudoers is world writable
今天误操作修改了/etc/sudoers的权限,将它的权限改成了777,结果就导致执行所有sudo的命令都报错。
sudo: /etc/sudoers is world writable
sudo: no valid sudoers sources found, quitting
想重新把它的权限修改回去,但是执行chmod 440 /etc/sudoers后却发现报错为:
chmod: Unable to change file mode on /etc/sudoers: Operation not permitted
这就尴尬了,改不回去。
最后通过疯狂的百度谷歌,找到了一些解决方法,但是有些方法说的太简单了,还是走了好多冤枉路,现总结如下:
1.在Mac中启动root 账户
https://jingyan.baidu.com/article/49711c619e7620fa441b7ca8.html
2.切换到root用户,修改 /etc/sudoers的权限
1 #无法使用chmod修改权限 2 demo:Desktop piaoyu.qiu$ ls -la /etc/sudoers 3 -rwxrwxrwx 1 root wheel 1371 8 9 11:28 /etc/sudoers 4 demo:Desktop piaoyu.qiu$ chmod 440 /etc/sudoers 5 chmod: Unable to change file mode on /etc/sudoers: Operation not permitted 6 7 #切换到root用户 8 demo:Desktop piaoyu.qiu$ su 9 Password:你自己设置的密码 10 sh-3.2# ls -l /etc/sudoers 11 -rwxrwxrwx 1 root wheel 1371 8 9 11:28 /etc/sudoers 12 sh-3.2# chmod 0440 /etc/sudoers 13 sh-3.2# ls -l /etc/sudoers 14 -r--r----- 1 root wheel 1371 8 9 11:28 /etc/sudoers 15 sh-3.2# exit
完美解决问题,最后说一句Mac好烦人!!