Windows XCopy function on Linux


I have a directory named "dir1"; "dir1" has subdirectories and files.

I need a command that copies "dir1" to another location, with all the files and subdirectories structure (if a subdirectory doesn't exist on the target, it must create it), but i need that such command displays what it is doing.

Is this possible to do?
Who is Participating?
cp -r (recursively)
cp -v (verbose, show every file/directory has ben copied over)
cp -p (preserve the file/dir permission)

As combine,
/bin/cp -pvr  /path-to-dir1   /path-to-dir2   # if dir2 doesn't exist, then it is created as well as the sub-dir
cp -pvr dir1 dir2
kalvilloAuthor Commented:
I have a problem... I already copied all the files using the procedure explained above, but, the files are inaccessible, because only root has access to them.

Is it possible to copy, preserving the permissions from the source?
You mean ownership, since your do "cp" as root?
-p have preserve the permission to make the target have the same permission as the source.

But the ownership will become whoever you run "cp".
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.