How to copy files from one user account to another an retain all file permissions from original account?

We have a system set up into multiple development accounts that basically has multiple copies of the same base system setup. How can I copy all the files from one account's home directory (from /newark) to another (for example, /newark4) and retain the exact same file permissions (owner, group, read/write, etc.), including for sub-directories?
Who is Participating?
chris_calabreseConnect With a Mentor Commented:
Assuming you have proper permissions to overwrite the files...

(cd /newark && tar cf - the_directory) |
(cd /newark4 && tar xf -)

Where "the_directory" is the directory in /newark you want to copy (or '.' if you want the whole thing).
maknightAuthor Commented:
This did everything correct except for links, but that is not a big deal. There is only one directory link.
There are options to tar, cpio, and pax (all are similar and can solve this problem) to handle links in various ways.  See the respective man pages.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.