I had my file/folder ownerships screwed up, so I thought I "restore" them by applying

chown -Rh root:root /

and then

chown -Rh *username*:users /home/*username*

I did not know that some files are not owned by root, so now I can't use sudo and some other services.

Is my os wrecked now or is there a way to restore the ownerships to defaults? Which files/folders are neither owned by root nor user?

  • 5
    Your OS is wrecked indeed. Time to reinstall. – forcefsck Dec 28 '15 at 16:16
  • 1
    When you chown any suid file, the suid bit is unset. Hence why sudo doesn't work anymore. – Wildcard Dec 28 '15 at 16:22

You could try to "refresh" the install of all the system (i.e., in the case of Fedora, ask to reinstall all packages), and fix up leftovers (user's home directories, files served e.g. by the webserver) by hand afterwards.

I very much doubt this is substantially less work than doing a clean install, and there will always the lingering doubt of some files with wrong ownership (which, given Murphy's law, will bite you in some nasty way at the worst possible moment).

Count it towards the Unix/Linux way learning experience: The system puts you in charge, and doesn't try to second guess your orders. If you ask to destroy the system, it will happily comply, no questions asked. With awesome power come high responsibilities.

  • 1
    I wouldn't trust any system 'fixed' by this method, with anything more important than experimental testing. – Don Simon Dec 28 '15 at 16:48
  • @DonSimon, neither would I. I hope(d) this was clear from my answer... – vonbrand Dec 28 '15 at 20:18
  • 1
    On a .rpm system you can potentially restore default ownership and permissions without reinstalling . See - adminlinux.org/2009/07/how-to-restore-default-system.html or similar – Panther Dec 29 '15 at 0:31
  • @bodhi.zazen, thanks, interesting link. But (as DonSimon also says) I wouldn't trust such a "repaired" system to give me the day of the month. – vonbrand Dec 29 '15 at 0:36
  • @vonbrand It works fine on rpm systems (this is one advantage of .rpm) – Panther Dec 29 '15 at 0:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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