【Centos7进入root权限是报错:sudo: /etc/sudo.conf is owned by uid 1000, should be 0】

将远程服务器设置为禁止使用root登录,在使用用户登录后,进入root权限失败
,这是由于在Centos上安装ftp服务时错误的批量修改了系统根目录全部文件的权限,导致进入root权限时出现报错:

sudo: /etc/sudo.conf is owned by uid 1000, should be 0
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set

执行命令

chown root:root /etc/sudo.conf -R
chmod 4755 /usr/bin/sudo

执行sudo ,出现错误

su: Authentication failure

执行命令

chown -R root:root /etc/sudoers.d
chown root:root /etc/sudoers

执行sudo命令,出现错误

sudo: error in /etc/sudo.conf, line 19 while loading plugin "sudoers_policy"
sudo: /usr/libexec/sudo/sudoers.so must be owned by uid 0
sudo: fatal error, unable to load plugins

执行命令 =====》

chmod 644 /usr/libexec/sudo/sudoers.so
chown -R root /usr/libexec/sudo/

执行sudo,出现错误

sudo: /var/db/sudo/lectured is owned by uid 1000, should be 0
dog is not in the sudoers file.  This incident will be reported.

执行命令

chown root:root /var/db/sudo/lectured/

执行命令sudo,出现错误

dog is not in the sudoers file.  This incident will be reported.

执行命令

[root@myyuncentos ~]# chmod u+x /etc/sudoers
[root@myyuncentos ~]# vi /etc/sudoers

找到这行 root ALL=(ALL) ALL,在他下面添加xxx ALL=(ALL) ALL (这里的xxx是你的用户名)
执行命令

chmod u-w /etc/sudoers

在执行sudo,输入密码可以进入root权限了====》

在sudoers文件中,可以sudoers添加下面四行中任意一条
youuser ALL=(ALL) ALL  //允许用户youuser执行sudo命令(需要输入密码).
%youuser ALL=(ALL) ALL	//允许用户组youuser里面的用户执行sudo命令(需要输入密码).
youuser ALL=(ALL) NOPASSWD: ALL   //允许用户youuser执行sudo命令,并且在执行的时候不输入密码.
%youuser ALL=(ALL) NOPASSWD: ALL   //允许用户组youuser里面的用户执行sudo命令,并且在执行的时候不输入密码.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Michael.Scofield

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值