[daily][centos][sudo] sudo 报错

时间:2021-07-10 12:22:54

有时候, 比如在CentOS 6上. sudo 会报如下错误:

sudo: must be setuid root

这是因为, sudo 命令, 没有SUID,

[root@T209 ~]# ll /usr/bin/sudo
-rwxr-xr-x. root root Jun /usr/bin/sudo

使用如下命令, 增加SUID:

[root@localhost ~]# chmod u+s /usr/bin/sudo
[root@localhost ~]# ll /usr/bin/sudo
-rwsr-xr-x. root root Jun /usr/bin/sudo

参考:https://www.sudo.ws/troubleshooting.html

Q) Sudo compiles and installs OK but when I try to run it I get:
effective uid is not , is /usr/local/bin/sudo on a file system with the
'nosuid' option set or an NFS file system without root privileges?
A) The owner and permissions on the sudo binary appear to be OK but when
sudo ran, the setuid bit did not have an effect. There are two common
causes for this. The first is that the file system the sudo binary
is located on is mounted with the 'nosuid' mount option, which disables
setuid binaries. The output of the "mount" command should tell you if
the file system is mounted with the 'nosuid' option. The other possible
cause is that sudo is installed on an NFS-mounted file system that is
exported without root privileges. By default, NFS file systems are
exported with uid mapped to a non-privileged uid (usually -). You
should be able to determine whether sudo is located on an NFS-mounted
filesystem by running "df `which sudo'".