February 24, 2004

Recursively copy files and their permissions

Need to copy files while preserving permissions? Use this simple tar command to recursively duplicate a directory tree with full fidelity.

# cd /oldir tar cf - . | (cd /newdir ; tar xf -)
This is the best way to totally preserve a copy of a directory tree between the current directory and /newdir