I accidentally set owner of root folder (/) and all subfolders to one user by command
我不小心通过命令将根文件夹(/)和所有子文件夹的所有者设置为一个用户
$ sudo chown -R 'userName' /*
Now I wanna set owner back to root user by command
现在我想通过命令将所有者设置回root用户
$ chown -R root:root /*
But I have no permission for this operation. If i use command
但是我没有这个操作的许可。如果我使用命令
$ sudo chown -R root:root /*
it returns
sudo: effective uid is not 0, is sudo installed setuid root?
What should I do to fix that?
我该怎么做才能解决这个问题?
3 个解决方案
#1
3
I am guessing when you ran the first command you also ended up modifying the ownership of the /usr/bin/sudo
executable.
我猜你在运行第一个命令时也最终修改了/ usr / bin / sudo可执行文件的所有权。
It is saying that effective UID isn't 0 (since root has EUID equal to 0).
它说有效UID不为0(因为root的EUID等于0)。
So try to change owner of /usr/bin/sudo
, and then try change the ownership of other files.
因此,尝试更改/ usr / bin / sudo的所有者,然后尝试更改其他文件的所有权。
#2
2
You broke your system pretty badly. Next time be more careful using sudo
.
你打破了你的系统非常糟糕。下次使用sudo时要小心点。
- Now, start your system using a rescue disk, probably your install disk.
- Mount your broken file system in the rescue system.
- Fix the permission/owner stuff.
- Reboot using your original system.
现在,使用救援磁盘启动系统,可能是您的安装磁盘。
将损坏的文件系统安装在救援系统中。
修复权限/所有者的东西。
使用原始系统重新启动。
Depending on how much you changed using that chown
, you will have to fix a lot in step 3. You probably might want to have a look at a working proper installation of the same system to find out which user should be the owner of things like /dev/mem
etc.
根据您使用该chown进行了多少更改,您必须在第3步中进行大量修复。您可能希望查看同一系统的正常安装,以找出哪些用户应该是/ dev / mem等
A re-install of the OS might be faster.
重新安装操作系统可能会更快。
#3
2
:O I offer my condolence!
:哦,我表示哀悼!
The problem is that the sudo binary itself must be owned by root. If you have the root password you could just get root to fix the problem:
问题是sudo二进制文件本身必须由root拥有。如果你有root密码,你可以直接修复问题:
su
If not, you could boot using a rescue system, mount the partition and
如果没有,你可以使用救援系统启动,安装分区和
chown root:root /mnt/usr/bin/sudo
or fix the whole problem using the rescue system.
或使用救援系统解决整个问题。
But it will be hard to fix all that ownerships. I would suggest to craft a script that reads the file ownerships from a vanilla installation of your system (having installed the same packages as you) and applies them to the crashed system. (Custom files in the /home/... you'll have to chown
yourself) Without such a script it will get really hard but it should be easy to code that
但是很难解决所有的所有权问题。我建议制作一个脚本,从你系统的vanilla安装中读取文件所有权(安装了与你相同的包)并将它们应用到崩溃的系统中。 (/ home /中的自定义文件......你必须自己编辑)如果没有这样的脚本,它会变得非常困难,但它应该很容易编码
#1
3
I am guessing when you ran the first command you also ended up modifying the ownership of the /usr/bin/sudo
executable.
我猜你在运行第一个命令时也最终修改了/ usr / bin / sudo可执行文件的所有权。
It is saying that effective UID isn't 0 (since root has EUID equal to 0).
它说有效UID不为0(因为root的EUID等于0)。
So try to change owner of /usr/bin/sudo
, and then try change the ownership of other files.
因此,尝试更改/ usr / bin / sudo的所有者,然后尝试更改其他文件的所有权。
#2
2
You broke your system pretty badly. Next time be more careful using sudo
.
你打破了你的系统非常糟糕。下次使用sudo时要小心点。
- Now, start your system using a rescue disk, probably your install disk.
- Mount your broken file system in the rescue system.
- Fix the permission/owner stuff.
- Reboot using your original system.
现在,使用救援磁盘启动系统,可能是您的安装磁盘。
将损坏的文件系统安装在救援系统中。
修复权限/所有者的东西。
使用原始系统重新启动。
Depending on how much you changed using that chown
, you will have to fix a lot in step 3. You probably might want to have a look at a working proper installation of the same system to find out which user should be the owner of things like /dev/mem
etc.
根据您使用该chown进行了多少更改,您必须在第3步中进行大量修复。您可能希望查看同一系统的正常安装,以找出哪些用户应该是/ dev / mem等
A re-install of the OS might be faster.
重新安装操作系统可能会更快。
#3
2
:O I offer my condolence!
:哦,我表示哀悼!
The problem is that the sudo binary itself must be owned by root. If you have the root password you could just get root to fix the problem:
问题是sudo二进制文件本身必须由root拥有。如果你有root密码,你可以直接修复问题:
su
If not, you could boot using a rescue system, mount the partition and
如果没有,你可以使用救援系统启动,安装分区和
chown root:root /mnt/usr/bin/sudo
or fix the whole problem using the rescue system.
或使用救援系统解决整个问题。
But it will be hard to fix all that ownerships. I would suggest to craft a script that reads the file ownerships from a vanilla installation of your system (having installed the same packages as you) and applies them to the crashed system. (Custom files in the /home/... you'll have to chown
yourself) Without such a script it will get really hard but it should be easy to code that
但是很难解决所有的所有权问题。我建议制作一个脚本,从你系统的vanilla安装中读取文件所有权(安装了与你相同的包)并将它们应用到崩溃的系统中。 (/ home /中的自定义文件......你必须自己编辑)如果没有这样的脚本,它会变得非常困难,但它应该很容易编码