Copying Files Using cp
To copy files, we could use the cp command. The general format of the command when used for simple copying is as follows:
matthew@seymour:~$ cp -a source_directory target_directory
The -a argument is the same as giving -dpR, which would be
• -d—Preserves symbolic links (by not dereferencing them) and copies the files that they point to instead of copying the links.
• -p—Preserves all file attributes if possible. (File ownership might interfere.)
• -R—Copies directories recursively.
The cp command can also be used to quickly replicate directories and retain permissions by using the -avR command-line options. Using these options preserves file and directory permissions, gives verbose output, and recursively copies and re-creates ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access