19

I want to transfer lots of files/folders from Windows to Linux using Rsync. On linux server(destination), I want the file permission set to 644, and folder permission set to 755. If possible, I want the ownership set to root.root for all the files/folders. I have tried -p option, but it doesn't work. Thank you for any help.

1
  • Try umask 022 before your copy.
    – BillThor
    Commented Feb 10, 2011 at 6:21

2 Answers 2

36

You can set the perms using the --chmod parameter e.g.

--chmod=Du=rwx,Dgo=rx,Fu=rw,Fog=r 

will force the permissions to be set to 755 for Directories and 644 for Files.

5
  • Thanks. The folder seems change to 744(drwxr--r--). Anyway, I decide to change the permission after transfer.
    – garconcn
    Commented Feb 11, 2011 at 21:42
  • 9
    The --chmod also accepts octal mode numbers, which in my opinion is easier to visualize the permission given: --chmod=D2775,F664 Commented Apr 23, 2014 at 18:47
  • You can also use --chmod o=rX in order to automatically give folders the x flag, but omit it from files.
    – hachre
    Commented Apr 22, 2018 at 2:41
  • 1
    Do you need to specify --perms as well?
    – OrangeDog
    Commented Sep 20, 2018 at 12:17
  • @OrangeDog Yes. The correct usage is: --perms --chmod=Du=rwx,Dgo=rx,Fu=rw,Fog=r Commented Apr 1, 2023 at 13:08
12

The --chmod argument syntax mentioned in the above is not quite accurate. When you specify owner, group, or other, and don't precede it with a "D" or a "F", it will apply that to all types of files, and it will apply the last parameter it finds as the default. This would explain why your directories were coming out as 744, since the last parameter in the argument was og=r.

Try this instead:

--chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .