To preserve file permissions when copying files in Linux, you can use the cp command with the -p option. This option preserves the file's mode, ownership, and timestamps. Here’s how to do it:
cp -p source_file.txt destination_file.txt
If you are using rsync, you can also preserve permissions by using the -a (archive) option, which includes preserving permissions along with other attributes:
rsync -a source_file.txt destination_directory/
Both methods ensure that the original file permissions are maintained in the copied file.
