I own everything! (did 'chown -R' in the wrong place)
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Recursively changing permissions of ownership of files is not something that has an "undo" option, and unfortunately I would say that your only option is to reinstall.
To illustrate the problem, once permissions or ownership has been changed, there's no way to restore the previous value, and thus, if you have 200 files in a certain directory and some of them were owned by root, others by user A, and others by user B, after the chown operation they'll all show under the one single user. How can you tell which ones previously belonged to root, or A, or B? You can't, hence the only safe thing to do is reinstall.
Reinstalls aren't that big of a deal though, assuming that you've made /home in its own partition. If so, just make sure to leave /home as is (do not reformat it). You should be back up and running pretty quickly. Good luck with it
To illustrate the problem, once permissions or ownership has been changed, there's no way to restore the previous value, and thus, if you have 200 files in a certain directory and some of them were owned by root, others by user A, and others by user B, after the chown operation they'll all show under the one single user. How can you tell which ones previously belonged to root, or A, or B? You can't, hence the only safe thing to do is reinstall.
Well... I only changed the files and directories belonging to root. So that should be reversible.
I promised myself not to work on it till wednesday (I have two tests in between). But I think I should be able to chown back. I am able to longin as root with the 'rescue-system' - option.
chown - man:
Code:
--from=CURRENT_OWNER:CURRENT_GROUP
change the owner and/or group of each file only if its current
owner and/or group match those specified here. Either may be
omitted, in which case a match is not required for the omitted
attribute.
Well... I only changed the files and directories belonging to root. So that should be reversible.
Maybe I'm not understanding your question. To illustrate, suppose you have 3 files, one (file "A") owned by root and the other two (files "B" and "C") owned by user. If you chmod so that they all three are owned by user, then you have no way of determining that file "A" originally was owned by root. Consequently, if you later peform another chmod on these same three files to set everything back to being owned by root, then you'll end up with "B" and "C" being owned by root, which is just as bad.
yes, but I chmodded with the '--from' option (see above).
But anyways, it didn't work. Looks like I have to re-install. Wich is not that bad, I can now rethink my partitioning.
Well it is bad, I have to redo so much crap, but at least I'll remember to do a system backup.
Thanks everybody.
You could chown root:root -R / however as others pointed out some services (apache, mysql, bind, etc.) depend on file ownership for proper secure operation, particularly chrooted apps. Unfortunately your best course is to back up /home and /etc (and /var/lib/mysql, /var/srv or /var/www, etc.) and then reformat/reinstall.
But look at it this way: you're wise enough to realize that this is a problem. I have (er, HAD, and good riddance!) a client who INSISTS on chmod -R 777 / on his OS/X boxes - and he wonders why he used to get hacked all the time (and I heard they are getting pwned again).
Why did he do this? They love MacOS's total lack of security, and HATE security (and yet they want a secure network? HA!). They know better and they do it anyway. We lost them because we would not agree to open up their boxes, just specific shares for moving files. They view security as inconvenient, despite their boxes having been repeatedly hacked in the past. Last I heard from friends who work there, they're back to the shenanigans and get hacked regularly. Sad thing is they do work for the Navy and a fortune-100 company. If they were ever to get audited for security by either client, they'd lose their bread-and-butter contracts instantly.
Try with a live cd. chroot to the partion and change the ownership rights.
Thanks for pointing out 'chroot' didn't know that one.
The chowning back does work, but something is still broke. Kde refuses to start in normal mode, I guess due to my configuration files now belonging to root. Anyway, I'll re-install, who knows what else is broke. I'd rather spend two hours re-configuring than repairing and risking an unstable system.
@KimVette - I didn't like the whole security thing at first, but after a few months I realized that I didn't have a single virus or been attacked once, even though I have apache and aMule running all the time. That more than justifies all the sudo chown and chmod stuff.
---
This is a great support group here, I appreciate the lack of 'RTFM!' and the whole closing, editing and deleting - threads stuff that seems to be pretty popular elsewhere.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.