Differences Between a and p Options in the cp Command

Asked 2 years ago, Updated 2 years ago, 131 views

When I copied all of the directories below the specified directory in CentOS cp-a, some of the permissions were changed.

Specifically, I was doing 777 recursively in the image directory, but I changed it to 777 again because an error occurred due to some changes.
cp-a I thought it would be exactly the same as the original directory, so I was quite surprised.
色々 I've been working on a lot of things, so I might have misunderstood something

Question
·What is the difference between cp-a and cp-p?
·When I saw cp-a help, it said --archive same as-dR--preserve=all, so does it combine all cp-p?
·Or should I write cp-ap?

What do you want to do in the end
·I would like to copy everything with the same contents as the original directory
·Composition, content, mission, and timestamp
何 Assumptions for copying to an empty place.Copy content does not overlap, if any, overwrite all

linux unix

2022-09-30 21:11

1 Answers

http://linuxjm.osdn.jp/html/GNU_fileutils/man1/cp.1.html
says -a is equivalent to -dpR.

Oira, don't use cp to copy the entire directory structure to your seniors,
I was told to use tar or cpio.

/home/alice/projects/zuluTo copy the entire following to /home/bob/zulu,
(Assuming the destination has write permission)

(cd/home/alice/projects&&tar cf-zulu)|(cd/home/bob&&tar xvf-)

cpio examples are left to others.
Is there a better way now?


2022-09-30 21:11

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.