Problem scenario
You want to recursively copy subdirectories from on Linux machine to another. How do you copy them into one file with the directory structure for the purpose of transferring it later?
Solution
On the source server go to the parent directory that you want to compress into one file. Run this tar command:
tar cvfz target.tgz subdirsource/
Now target.tgz will have all the directories of subdirsource.
# If you want to uncompress target.tgz, run this command from a directory where you can write to (e.g., have permissions to create subdirectories):
tar zxvf target.tgz