Thursday, February 12, 2009

Copy entire contents of a directory and preserve permissions

Sometimes we have to copy a directory with all contents and we have to preserve all permissions on content of directory.
This can be easily done using 'tar' command. For this issue command

cd source && tar -cf - . | (cd destination && tar -xpvf -)

where
source : Directory which you want to copy
destination : directoty where you want to move