2018-05-23 sudoer

From http://broncodev.com/2016-06-16-fixing-the-etc-sudoers-d-is-world-writable/

【Goooood】Fixing the 'sudo: /etc/sudoers.d is world writable' problem

Posted on June 16, 2016
I’ve just helped a colleague with a problem (beyond the mental one), when he tried to execute sudo. For some reason, EVERYTHING in his /etc/ had 777 permission - that’s why the sudo: /etc/sudoers.d is world writable. I tried to login as root, executing su, but su: Authentication failure was shown… how could I change the permissions if I wasn’t able to login as root? Follow the instructions above to solve this problem.

To login as root, without su or sudo, you can use pkexec:

pkexec su

Now change the files’ permissions:

chmod 440 /etc/sudoers

chmod 775 /etc/sudoers.d
chmod 440 /etc/sudoers.d/README
That’s all - now you must be able to sudo.


添加sudoer

way 1
sudo vim /etc/sudoers

  1. 进入超级用户模式。也就是输入”su root”,系统会让你输入超级用户密码,输入密码后就进入了超级用户模式。(当然,你也可以直接用root进入修改)
  2. 添加文件的写权限。也就是输入命令”chmod u+w /etc/sudoers”。
  3. 编辑/etc/sudoers文件。也就是输入命令”vim /etc/sudoers”,进入编辑模式,找到这一 行:”root ALL=(ALL) ALL”(会用vim编辑器的可以使用“/root ALL=(ALL)ALL”定位)在起下面添加”xxx ALL=(ALL) ALL”(这里的xxx是你的用户名),然后保存退出。
  4. 撤销文件的写权限。也就是输入命令”chmod u-w /etc/sudoers”。

way 2
sudo visudo

你可能感兴趣的:(2018-05-23 sudoer)