Why did all my folders get CHOWNed to root on copy??

michaelsanford

Translator, Web Developer
I have a LaCie 60GB external FW drive.

I wanted to back up my ~/* to it, because I am soon to upgrade to 10.2 (yay!)

Now, I couldn't access all the files by copying them with the Finder, I got all sorts of stupid "One or more of the files you selected can not be accessed at this time, continue?" -type-errors. So I copied them in the terminal with:

[gwailo:~]% sudo cp -r * /volumes/hermes/

BUT for some reason after the files had all copied, the permissions of some of the folders (Movies, Pictures, and Desktop) had changed to root. That is, the owner had changed.

I fixed it with [localhost:/volumes/hermes/gwailo] root# chown -R gwailo:staff *

My question, what would have caused all this automatic, unprovoked chown-ing at copy?
 
Not only were the folder permissions changed, but all the files in the folders as well.

I was also unable to view the contents of the folder without switching to su, and I got the little "No Entry" mini-icon on those folders in the Finder.
 
When you copy something as root, root becomes the owner. If you wanted it to preserver the permissions/ownership, then you could have had to tell it to do so like so...

sudo cp -rp * /Volumes/hermes

The p switch preserves all sorts of stuff like permissions, ownership, access times, etc.

man is your friend :)
 
Man is my friend indeed.

I would have caught on that that was the problem if it had changed ALL of the file permissions; what tripped me up was that only SOME of the files were altered...

By your explanation, shouldn't ALL the files have been touched to root?
 
Perhaps, on your destination volume, the stuff that didn't change ownership, already existed and the stuff that didn't exist before did infact get touched as root. This could have happened when you tried to initally copy your stuff with the finder. Finder was able to copy some stuff(that you permissions for) and thus setup up the initial framework. Then when you issued the cp command via the cli, it got all the rest of the stuff that finder hiccuped on and the stuff that you had already copied before. If Root overwrites an already existing file, it does not change the permissions and ownership... only when the file does not already exist does root then become the owner(if the -p switch wasn't used that is)

I am not at my mac right this second so I can't actually check the man page for cp but when I check it on my Freebsd server, it mentioned all that said above.
 
No, I reformatted, tried to copy with the Finder, failed, deleted the partial backup, emptied the trash, then used the cli. It is possible that I rushed and started copying with the cli before the trash was empty however: For some reason whenever I use the cli to copy ~ it starts with the ~/Music folder, which was one of the touched ones anyway.

That is however, a possibility.

In any event my problem's been solved, I just have to use the -rp switch and it won't happen again...I presume ha!

Thanks for your replies BSDimwit! :)
 
Back
Top