使用 chmod 后根目录“/”被锁定

sym*_*m44 3 permissions root chmod

我不小心用了

sudo chmod 3 /
Run Code Online (Sandbox Code Playgroud)

它赋予根目录执行和写入权限,同时删除读取权限。我怎么能从中恢复,我sudo现在甚至无法使用。

Syl*_*eau 7

由于您不能使用sudo,请改为尝试以下命令(您将通过pkexec获得 root 权限):

pkexec chmod 755 /
Run Code Online (Sandbox Code Playgroud)

在虚拟机中测试正常:

u@u-VirtualBox:/$ sudo chmod 3 /
[sudo] password for u: 
u@u-VirtualBox:/$ ll
ls: cannot open directory .: Permission denied
u@u-VirtualBox:/$ sudo chmod 755 /
sudo: unable to stat /etc/sudoers: No such file or directory
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
u@u-VirtualBox:/$ pkexec chmod 755 /
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===
Authentication is needed to run `/bin/chmod' as the super user
Authenticating as: u,,, (u)
Password: 
==== AUTHENTICATION COMPLETE ===
u@u-VirtualBox:/$ ll
total 104
drwxr-xr-x  23 root root  4096 oct.  12 20:22 ./
drwxr-xr-x  23 root root  4096 oct.  12 20:22 ../
[...]
u@u-VirtualBox:/$ 
Run Code Online (Sandbox Code Playgroud)

  • @AndreaLazzarotto:我在 VM 中测试了 OP 命令,`pkexec` 恢复了对 `/` 的初始权限。查看我的日志。 (3认同)