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

Mikhail Panteleev picture Mikhail Panteleev · Jul 3, 2013 · Viewed 20.9k times · Source

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

$ 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?

Answer

jaypal singh picture jaypal singh · Jul 3, 2013

I am guessing when you ran the first command you also ended up modifying the ownership of the /usr/bin/sudo executable.

It is saying that effective UID isn't 0 (since root has EUID equal to 0).

So try to change owner of /usr/bin/sudo, and then try change the ownership of other files.