Permissions & Ownership
Permission Flags
| Flag | Effect |
|---|---|
-a | Preserves perms, owner, group, times (archive) |
-p | Preserve permissions only |
-o | Preserve owner (requires root) |
-g | Preserve group |
--chmod=RULE | Set permissions on destination |
--chown=USER:GROUP | Set ownership on destination |
--no-perms | Don't preserve permissions |
--no-owner | Don't preserve owner |
--no-group | Don't preserve group |
-A | Preserve ACLs |
-X | Preserve extended attributes |
Common Patterns
# Preserve everything (standard)
rsync -av src/ dest/
# Set specific permissions on destination
rsync -av --chmod=D755,F644 src/ dest/
# Set ownership on destination
rsync -av --chown=www-data:www-data src/ dest/
# Ignore permissions (copy to NTFS/FAT)
rsync -av --no-perms --no-owner --no-group src/ /mnt/usb/
# Full metadata (Linux → Linux, both support ACLs)
rsync -avAX src/ dest/
# Fix permissions after transfer
sudo chown -R www-data:www-data /var/www/html/
sudo find /var/www/html/ -type d -exec chmod 755 {} \;
sudo find /var/www/html/ -type f -exec chmod 644 {} \;
tip
--chmod=D755,F644 sets directories to 755 and files to 644 — the standard for web servers.