Back to Raspberry Pi Taiwan

【教學/常見問與答】sudo: effective uid is not 0, is sudo installed setuid root?

Last Updated on 2022 年 7 月 19 日 by 小編

sudo: effective uid is not 0, is sudo installed setuid root
圖片來源:sudo: effective uid is not 0, is sudo installed setuid root? #13

is sudo installed setuid root 問題

在某些情況下,sudo 會突然失靈,回傳錯誤訊息如: sudo: effective uid is not 0, is sudo installed setuid root?

is sudo installed setuid root 解決方法

1. 修改 /boot/cmdline.txt

將 SD 卡接到其他電腦,在 /boot/cmdline.txt 最後面加上 single

2. single user mode

將 SD 卡插回 Raspberry Pi,重新啟動後將會進入 single user mode

3. 修改擁有者和群組權限

/usr 的擁有者和群組改成 root,並修改全部權限為 rX

chown -R root:root /usr
chmod -R a+rX /usr

4. 更改 sudo 相關檔案的使用者和權限

chown root:root /usr/lib/sudo/sudoers.so
chown -R root:root /etc/sudoers*
chmod 4755 /usr/bin/sudo

5. 測試

su - pi
sudo
usage: sudo [-D level] -h | -K | -k | -V
usage: sudo -v [-AknS] [-D level] [-g groupname|#gid] [-p prompt] [-u user name|#uid]
usage: sudo -l[l] [-AknS] [-D level] [-g groupname|#gid] [-p prompt] [-U user name] [-u user name|#uid] [-g groupname|#gid] [command]
usage: sudo [-AbEHknPS] [-r role] [-t type] [-C fd] [-D level] [-g groupname|#gid] [-p prompt] [-u user name|#uid] [-g groupname|#gid] [VAR=value] [-i|-s] []
usage: sudo -e [-AknS] [-r role] [-t type] [-C fd] [-D level] [-g groupname|#gid] [-p prompt] [-u user name|#uid] file ...

6. 取消 single user mode

single user mode 取消後重開機就大功告成了。

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

Back to Raspberry Pi Taiwan