Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I ran cp -a Folder1/* Folder2/ and cp -p Folder1/* Folder2/
It seems like in both cases, all files were copied from Folder1 to Folder2 while preserving their original permissions , owners and groups and timestamps. I was not able to see the difference with both commands
As posted -a = --preserve=all --no-dereference --recursive
--perserve=all -> all = mode,ownership,timestamps and if possible additional attributes: context, links, xattr
-p == --preserve=mode,ownership,timestamps
With respect to the output of the ls command there should be no difference between attributes of the two files. If you want to see the extended attributes for the files you can use the getxattr command.
With -a you also have the additional options
-d same as --no-dereference --preserve=links
Which means copy symbolic links as symbolic links rather than copying the files that they point to, and preserve hard links between source files in the copies. If the folders do not contain links then you are not going to see a difference.
I now see that the cp -a is a better option as it preserves all attributes of the original file.
However, it does that at the cost of adding a --recursive option. You might not always want a recursive copy. If you want to preserve all the attributes of the original file, then you can use either the shortcut --perserve=all or else the full list --preserve=mode,ownership,timestamps,context,links,xattr plus --no-dereference
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.