cp -p Command: Copy Files with Preserved Attributes
The 'cp -p' command is used to copy files or directories and preserve their permissions, timestamps, and ownership. The '-p' option stands for 'preserve' and it ensures that the copied files or directories retain their original attributes. This command is often used when making backups or when transferring files between systems to ensure that the copied files have the same properties as the original ones.
For example, to copy a file named 'file1.txt' from the current directory to a directory called 'backup' while preserving its attributes, the following command can be used:
cp -p file1.txt backup/
This will create a copy of 'file1.txt' in the 'backup' directory with the same permissions, timestamps, and ownership as the original file.
原文地址: https://www.cveoy.top/t/topic/odvK 著作权归作者所有。请勿转载和采集!