?
Solved

Windows XCopy function on Linux

Posted on 2011-04-25
4
Medium Priority
?
673 Views
Last Modified: 2012-05-11
Hi.

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?
0
Comment
Question by:kalvillo
  • 3
4 Comments
 
LVL 38

Expert Comment

by:wesly_chen
ID: 35463561
cp -pvr dir1 dir2
0
 
LVL 38

Accepted Solution

by:
wesly_chen earned 2000 total points
ID: 35463574
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
0
 

Author Comment

by:kalvillo
ID: 35469267
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?
0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 35469371
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".
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
I have written articles previously comparing SARDU and YUMI.  I also included a couple of lines about Easy2boot (easy2boot.com).  I have now been using, and enjoying easy2boot as my sole multiboot utility for some years and realize that it deserves …
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month15 days, 14 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question