Change the owner of the root folder and subfolders (Ubuntu 13.04)

I accidentally set the owner of the root folder (/) and all subfolders to one user by command

$ sudo chown -R 'userName' /* 

Now I want to return the root owner to root

 $ chown -R root:root /* 

But I do not have permission for this operation. If I use the command

 $ sudo chown -R root:root /* 

he returns

  sudo: effective uid is not 0, is sudo installed setuid root? 

What should I do to fix this?

+6
source share
3 answers

I assume that when you ran the first command, you also changed ownership of the executable /usr/bin/sudo .

The effective UID is said to not be 0 (since root has an EUID of 0).

So, try changing the ownership of /usr/bin/sudo , and then try changing the ownership of other files.

+3
source

: O I offer my condolences!

The problem is that the sudo file itself must be owned by root. If you have a root password, you can simply run root to fix the problem:

 su 

If not, you can download the rescue system, install the partition and

 chown root:root /mnt/usr/bin/sudo 

or fix the whole problem with the rescue system.

But it will be difficult to fix all this. I would suggest creating a script that reads the file owners from the vanilla installation of your system (installed the same packages as you), and applies them to the broken system. (The user files in / home / ... you will have to chown yourself) Without such a script, it will be very heavy, but it will be easy to link the code with this

+2
source

You messed up your system a lot. Next time, be more careful when using sudo .

  • Now start your system with a rescue disk, possibly your installation disk.
  • Install your damaged file system in the recovery system.
  • Correct permission / owner material.
  • Reboot using the original system.

Depending on how much you changed with this chown , you will need to fix a lot in step 3. You might want to look at the correct installation of the same system to find out which user should be the owner of things like /dev/mem etc.

Reinstalling the OS may be faster.

+2
source

Source: https://habr.com/ru/post/948637/


All Articles