Skip to main content

Permissions & Ownership

Permission Flags

FlagEffect
-aPreserves perms, owner, group, times (archive)
-pPreserve permissions only
-oPreserve owner (requires root)
-gPreserve group
--chmod=RULESet permissions on destination
--chown=USER:GROUPSet ownership on destination
--no-permsDon't preserve permissions
--no-ownerDon't preserve owner
--no-groupDon't preserve group
-APreserve ACLs
-XPreserve 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.