LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   cp -a or cp -R differences (https://www.linuxquestions.org/questions/linux-software-2/cp-a-or-cp-r-differences-141198/)

shanenin 02-01-2004 09:15 PM

cp -a or cp -R differences
 
I have been reading through man cp . I was trying to sort it out.
Code:

-a, --archive
              Preserve  as much as possible of the structure and attributes of
              the original files in the copy (but do  not  preserve  directory
              structure).  Equivalent to -dpPR.

What does that mean do not preserve directory structure
Code:

-p, --preserve
              Preserve the original  files'  owner,  group,  permissions,  and
              timestamps.

doesn't -R preserve like the -p option?
Code:

-R, --recursive
              Copy directories recursively, preserving non-directories.


snacky 02-01-2004 09:32 PM

No. -R is just for copying whole trees intact.

-a and -p are for something more subtle: keeping timestamps, permissions and ownership the same. This is useful for archiving but not for anything else.

For regular use, I assume -R is the option you're looking for.

shanenin 02-01-2004 09:45 PM

does -R keep permissions the same(not ownership)?

snacky 02-01-2004 10:01 PM

Depends on who's copying it.

Remember, cp has to write a new copy. The written files will normally be owned by the person who writes them, right? That's how it'll be with -R. So if you cp -R your friend's directory of files into your own home directory (e.g. "cp -R ~myfriend/mp3s/ ~"), the copy will be owned by YOU, not your friend.

I'm pretty sure you won't ever need -a or -p unless you're archiving stuff for backup purposes. Knowing cp -R is useful, however. It sounds like you're just reading through manpages in case you find something that happens to be worth knowing, am I right?

shanenin 02-01-2004 10:44 PM

I was following the LFS-5.0 book. so I was trying to read and understand what it was telling me to do. Just trying to make sence of it all:)

edit/added

I understand ownership would change, but was not sure about permissions.


All times are GMT -5. The time now is 09:53 AM.