LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   I own everything! (did 'chown -R' in the wrong place) (https://www.linuxquestions.org/questions/linux-newbie-8/i-own-everything-did-chown-r-in-the-wrong-place-424052/)

oskar 03-12-2006 07:46 AM

I own everything! (did 'chown -R' in the wrong place)
 
I have to mount my exchange harddisk as root, don't know why.

So I have to change the user permissions to get access. In a moment of cleverness I did chown instead of chmod, to be more specific:
Code:

chown -R --from=root 'me' /
In the mount directory :D

as a result I can't even log in as root anymore
Code:

$ su
pwd:
su: cannot set groups: operation not permitted

so...
what do I do?

I can do chown as user now, but it doesn't seem to work properly that way.

kevkim55 03-12-2006 08:38 AM

Boot with an installtion CD and run chown root on the directory ?

BinJajer 03-12-2006 01:12 PM

Sit down and cry? Use a livecd? Chown back to root?

J.W. 03-12-2006 04:26 PM

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

oskar 03-12-2006 11:25 PM

Quote:

Originally Posted by J.W.
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.


J.W. 03-13-2006 01:19 AM

Quote:

Originally Posted by oskar
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.

oskar 03-18-2006 01:02 PM

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.

prasanta 03-18-2006 02:10 PM

Try with a live cd. chroot to the partion and change the ownership rights.

KimVette 03-18-2006 09:54 PM

That stinks! :(

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.

oskar 03-19-2006 06:38 PM

Quote:

Originally Posted by prasanta
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.


All times are GMT -5. The time now is 11:19 AM.