公司服务器故障:
[chengsir@yinwucheng ~]$ sudo mkdir /opt/nginx
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
[chengsir@yinwucheng ~]$ su - root
Password:
su: Authentication failure
以下是解决方案:(前提必须要知道这个文件的默认权限)
两种方法:
方法一:进入单用户模式修改root密码,su和sudo没有关系,这时我们可以用su - root切到root用户,然后修改sudo权限,哪儿出了问题改哪里
[chengsir@yinwucheng ~]$ su - root
[root@yinwucheng ~]# ll -l /usr/bin/sudo
-rwxrwxrwx. 1 root root 147392 Oct 31 2018 /usr/bin/sudo
[root@yinwucheng ~]# chmod 111 /usr/bin/sudo
[root@yinwucheng ~]# ll -l /usr/bin/sudo
---x--x--x. 1 root root 147392 Oct 31 2018 /usr/bin/sudo
[root@yinwucheng ~]# chmod u+s /usr/bin/sudo
[root@yinwucheng ~]# ll -l /usr/bin/sudo
---s--x--x. 1 root root 147392 Oct 31 2018 /usr/bin/sudo
[root@yinwucheng ~]# ll -l /etc/sudoers
-rwxrwxrwx 1 root root 4352 Aug 26 19:47 /etc/sudoers
[root@yinwucheng ~]# chmod 440 /etc/sudoers
[root@yinwucheng ~]# ll -l /etc/sudoers
-r--r----- 1 root root 4352 Aug 26 19:47 /etc/sudoers
[root@yinwucheng ~]# su - chengsir
[chengsir@yinwucheng /opt]$ sudo mkdir cheng
[sudo] password for chengsir:
[chengsir@yinwucheng /opt]$ ll
total 0
drwxr-xr-x 2 root root 6 Aug 26 20:04 cheng
drwxr-xr-x 2 root root 6 Aug 26 14:52 xue
方法二:进入单用户修改sudoers权限为默认初始权限即可
重启进单用户模式:
第一步:查看sudo权限
ls -l /usr/bin/sudo
第二步:给sudo权限
chmod 111 /usr/bin/sudo
chmod u+s /usr/bin/sudo
第三步:给sudoers权限
chmod 440 /etc/sudoers
exec /sbin/init