mac sudo: /etc/sudoers is world writable

自从Mac版本升级之后,各种不适应,service 命令竟然没了,百度了一下说是要修改/etc/sudoers  ,在使用 chmod -R 777 /etc/sudoers 之后问题就来了,我竟然无法切换root用户,现在记录一下,解决办法

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 sudo: /etc/sudoers is world writable

上一篇:Linux 挂载命令


下一篇:CPU Cache模型与JMM