I am building a script to copy files from a remote server. The problem is, the remote servers file permissions are pretty whack and I don't want to copy these over.

The line in my script right now is

/usr/bin/rsync -rtzul --progress -e ssh "$DEFAULT_SSH:$REMOTE_DIRECTORY" "$LOCAL_DIRECTORY"

I have seen elsewhere that you can use the --chmod option to specify the permissions but I just don't understand the syntax for this argument! Perhaps I am being stupid?

I want to by default chmod files to 644 and directories to 755. I hope you can help me.

Many thanks!

1 Answer 1


OK, I have worked out how to do it! I had been digging for some time before asking this question and continued digging. The arguments I were looking for are -


To explain, this basically means:

Du = Directory Owner (Read, write, execute)

Dg = Directory Group (Read, execute)

Do = Directory Users (all) (Read, execute)

Fu = File Owner (Read, write)

Fg = File Group (Read)

Fo = File Users (all) (Read)

So in my case I have given directories 755 permissions and files 644 permissions.

I found out how to do this from - http://www.linux.com/learn/tutorials/309527-understanding-linux-file-permissions

  • I think you can write something shorter --chmod=Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r
    – Djidiouf
    Sep 9, 2015 at 5:36

You must log in to answer this question.

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