[英]sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set after chmod 755
What i tried is this: https://stackoverflow.com/a/29903645/4983983 我试过的是这个: https : //stackoverflow.com/a/29903645/4983983
I executed this: 我执行了这个:
n=$(which node); \
n=${n%/bin/node}; \
chmod -R 755 $n/bin/*; \
sudo cp -r $n/{bin,lib,share} /usr/local
but now i can not execute for example sudo su
command, i get following error: 但是现在我无法执行例如
sudo su
命令,出现以下错误:
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
I am not sure how can i redo it ? 我不确定该如何重做?
EDIT: Regarding @Bodo answer: 编辑:关于@Bodo答案:
sudo rpm --setperms mkdir
sudo rpm --setugids mkdir
cd /opt
mkdir test13121
mkdir: cannot create directory ‘test13121’: Permission denied
BUT:
sudo chown root:root /usr/bin/mkdir && sudo chmod 4755 /usr/bin/mkdir
mkdir test912121
The difficulty is to find out the normal permissions of the files you have changed. 困难在于找出已更改文件的普通权限。
You can try to reset the file permissions based on the information in the package management. 您可以尝试根据程序包管理中的信息重置文件权限。
See eg https://www.cyberciti.biz/tips/reset-rhel-centos-fedora-package-file-permission.html 参见例如https://www.cyberciti.biz/tips/reset-rhel-centos-fedora-package-file-permission.html
Citation from this page: 来自此页面的引用:
Reset the permissions of the all installed RPM packages
重置所有已安装的RPM软件包的权限
You need to use combination of rpm and a shell for loop command as follows:
您需要使用rpm和shell的组合来执行循环命令,如下所示:
for p in $(rpm -qa); do rpm --setperms $p; done for p in $(rpm -qa); do rpm --setugids $p; done
I suggest to read the linked page completely and try this for a single package first. 我建议您完整阅读链接的页面,并首先尝试使用单个软件包。 I guess you can somehow ask
rpm
to find the package name that contains eg /usr/bin/sudo
. 我想您可以以某种方式要求
rpm
查找包含/usr/bin/sudo
的软件包名称。 and try if the commands work for a single package. 并尝试命令是否适用于单个软件包。
Edit: If the setuid
or setgid
bits are not correct, you can try to change the order of the commands and use --setugids
before --setperms
. 编辑:如果
setuid
或setgid
位不正确,则可以尝试更改命令的顺序,并在--setugids
之前使用--setperms
。 (In some cases chown
resets setuid
or setgid
bits; don't know if this applies to the rpm
commands.) (在某些情况下,
chown
重置setuid
或setgid
位;不知道这是否适用于rpm
命令。)
There are sources in the internet that propose to combine --setugids
and --setperms
in one command or to use option -a
instead of a loop like 互联网上有一些来源建议在一个命令中结合使用
--setugids
和--setperms
或使用选项-a
而不是像这样的循环
rpm -a --setperms
Read the documentation. 阅读文档。 (I don't have an RPM based system where I could test the commands.)
(我没有可以测试命令的基于RPM的系统。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.