This question already has an answer here:

I am using a cloud server of godaddy & I don't have root password. My master user has root access through sudo. I was trying to create another user and set permission for a specific directory. I've created a news user testuser & created a new directory named "test" under var/www/html/. I was trying to set permission:

chmod -R 0777 /var/www/html/test

but unfortunately i press enter before mentioning the directory. That means I just change the whole permission

chmod -R 0777 /

Now, unfortunately I don't have root password & sudo, su are not working anymore. changing permission is showing

Operation not permitted

and sudo is showing the following error:

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

I've several project live on the server. is there any way to restore the user permission. I don't want to reinstall the whole cent OS.

I've checked the ls -l and all permission are set to drwxrwxrwx

Please help me solve the problem.

marked as duplicate by Iain, Ward, mdpc, HBruijn Aug 3 '16 at 7:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Also look at the related and linked section on the right of the duplicate. – Iain Aug 2 '16 at 11:07
  • Ahhhh.....backups? – mdpc Aug 2 '16 at 23:55

The only practical solution is to restore from backups.


If your centos allows passwordless root login in Single User Mode/Rescue Mode/Emergency mode, then you can use it to restore permissions.

Not the answer you're looking for? Browse other questions tagged or ask your own question.