Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I sync some folders within my Home folder between two Macs (running Lion and Mountain Lion) using Synk Pro, a commercial live file sync application. I have the same account name on both computers.

After syncing, some of my files on both computers are read-only, and they also aren't owned by me, but by the macports account – why?

Capture of the "Sharing & Permissions" section of a "Get Info" window, showing "macports" as the owner

To be able to modify files, I've used Get Info to change permissions of some files to read/write for 'everyone', and I used the app Permissions Reset to reset permissions back to original, but it doesn't change the permissions of sub-folders/files, and I have a huge file tree, so doing this manually is practically impossible. And Disk Utility does nothing to user data.

How can I fix this?

--
Added info:

As suggested, I ran the commands id -u and id -u macports on both computers. The result is that on the MacBook Pro, my account has uid 501 and macports has uid 502, and on the iMac it's the other way around.

share|improve this question
1  
@ArneStenström just edited my question. I don't get you second question, but not all my files is that way, but I can't track why anymore, because before I start to sync files, I copied some manually using AFP and using external HDD, I'm dealing with that situation for months, I really don't know when this started, I just modifying permissions to 'everyone' to w/r when I try to modify a file and I get a error. I know I messed everything even more. –  Vitim.us Mar 29 '13 at 16:29
1  
OH you're a genius! MPB id -u vitim 501 id -u macports 502 on iMac id -u vitim 502 id -u macports 501 –  Vitim.us Mar 29 '13 at 17:17
    
I executed sudo chown -R /Users/vitim/ on both computers and it fixed my files. I changed the Ownership option to Ignore, hopefully this will prevent my files turning ownership to macports. Please append your comment to your answer, so I can accept it. Thanks! –  Vitim.us Mar 29 '13 at 17:28
    
@ArneStenström - hmm let me think that over. Lets Ask Different Chat to see what's best for the site. –  bmike Apr 1 '13 at 14:44
    
thanks for editing, hopefully this will help someone else. –  Vitim.us Apr 1 '13 at 19:16
show 2 more comments

3 Answers 3

up vote 4 down vote accepted

The files appearing read-only to you is probably only because you are currently not their owner.
    What's likely happening is that the synced files retain the numeric owner-id from the source machine, and since that numeric uid in this particular case corresponds to the account macports on the target machine (in both transfer directions), macports has become the owner.

To verify that your account on each computer has the same numeric uid as the macports account has on the other machine, type the commands id -u and id -u macports in the Terminal in your account on both computers.

Fixing the cause of the problem

When information was submitted that the syncing is done using Synk Pro, I had a look at the Synk Pro web site and the app, and in the 'Advanced' settings I noticed the "Ownership:" option, which by default is set to "Copy If Possible".
    Since it looks like Synk Pro transfers files' numeric uid, and there's no option for mapping this uid to another uid/account on the target computer, the way to make synced files be owned by you is to change the "Ownership:" setting to "Ignore".

screen capture of Synk Pro's advanced "Ownership" option set to "Ignore"

Fixing the files

To fix the permission problem for the already synced files, you only need to change the owner of the files to your own account. Since (in this case) all of your synced folders are within your Home folder /Users/youraccount, you can do this with the following command in the Terminal when logged in to an administrator account (you'll have to give sudo the password of the admin account):

sudo chown -R youraccount /Users/youraccount

using the actual account name (also known as short user name) of your own account in place of youraccount. The account name is the same as the name of your account's Home folder in the /Users folder.
    This will change all files and folders within the folder /Users/youraccount to be owned by youraccount (-R is for recursive), which should give you write-access to all of your files.

Since you earlier gave write-permission to 'everyone' for some files to be able to modify them, you may want to remove those permissions. This command:

sudo chmod -R u+w,go-w /Users/youraccount

ensures that the owner of your files, and no-one else, has write permission on them.

Type man chown and man chmod for more info about these commands.


Advice against using Finder to fix a folder's permissions

(I will update the below later)

Note: It is possible to change ownership and permissions of all files and folders in a folder tree using the Finder, by use of the controls at the very bottom of the Sharing & Permissions section of a Get Info window as shown in the picture in the question. One problem with this is that an account's home folder, and the standard subfolders therein, such as Library, Documents, Public and so forth, have special permissions (by use of ACLs) preventing them from being deleted among other things, and you don't want these special permissions to be removed or propagated to other folders and even files, so you should not use this unless you know very well what you are doing.

share|improve this answer
    
The next time I edit this answer, I will mention more directly in the lead paragraph that Vitim's accounts on the two Macs have different uid. Seems like it was too obvious to mention ... –  Arne Stenström Apr 1 '13 at 22:19
add comment

There is a drag-and-drop freeware app with a GUI that can do this for you if you don't want to use Terminal commands. It is called BatChmod.

Be very careful in using it, or any other method; changing the privileges of a whole directory tree of files at once can have unintended consequences.

share|improve this answer
add comment

You can easily do to this in the shell (terminal) like on Linux using chmod

When using chmod, you have the three letters u, g, o (user, group, other) for defining the instance to which you want to give the permission. And the three letters r, w, x (read, write, execute) to define the kind of permission.

If you want to give all the read and execute permission, you would use chmod ugo +rx target. Similarly, you can take away permissions using - instead of +

share|improve this answer
    
How do I apply chmod to the entire directory tree? And change permissions but how I change the owner back to my user? –  Vitim.us Mar 29 '13 at 7:00
    
use chmod -R for the directory tree and chown user1 user2 to change ownership. –  bluewoodtree Mar 29 '13 at 17:19
    
Btw, why is my answer voted down? I think it works perfectly fine! –  bluewoodtree Mar 29 '13 at 17:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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