12

Besides the explanations from the man pages and --help information, in which way do the commands dd, cp and rsync differ when used to copy files? In which context is each of these superior to the others, for some definition of 'superior', so that it should get preference of use?

XavierStuvw
  • 1,119
  • 2
    Although I agree that the question is extremely broad and doesn't show that the man pages were actually read, the answer received seems to address it fairly well. For this reason, I think it should not be closed. – Julie Pelletier Jan 21 '17 at 03:02
  • Thanks for this comment. I have read the --help and man pages but I don't see an advantage in 'showing' that I have done it. The purpose of the question is indeed to eschew the technical jargon and have guidance around it. Which jargon may be daunting confusing to the novice. We have received a pretty thorough and to-the-point answer. – XavierStuvw Jan 21 '17 at 08:55

1 Answers1

19

They are completely different animals that better fit on different file or device manipulation cases:

dd

This command was created as a "copy and convert" utility, originally intended for converting files between the ASCII, little-endian, byte-stream world of DEC computers and the EBCDIC, big-endian, appearing at the first time on Unix Version 5. It became the de facto command utility to manipulate everything that can be mapped as a file inside your Unix-like operating system(clone a disc, backup of mbr, clone a disk as file, copy some blocks of one device file, write an image to a usb stick..), and piped to other commands, the sky is the limit. One alternative to this software is the dcfldd command.

dd related stuff:

cp

Make copy of files and directories. This is a more "higher" level of abstraction, where you can copy directories recursively, without caring about block size, file conversion, etc. It is a better tool to deal with "1-to-many" cases of file copy, ownership, symbolic link follow, recursively copy, and verbosity. However, it has it's limitations like dealing with file changes, remote copy, and those things better handled by rsync.

cp related stuff:

rsync

Can to copy files inside the same computer, but it's features are more useful on remote copy scenarios. Some of the features are ownership handling/manipulation, more easy "exclude" expressions for a better copy, file checksum to see if a file was already copied, delete origin files during or after copu, the use of a "transparent shell" by invoking the protocol wanted using a specific URI(ssh://, rsync://...), pipelining and other stuff that create optimized environment for remote mirroring things.

rsync related stuff:

Further Reading:

  • 5
    dd is also nicknamed Disk Destroyer – ychaouche May 06 '18 at 17:19
  • I read somewhere "block transfer vs file transfer". Probably dd is the former while cp and rsync are both the latter. That refers to what it is doing under the hood, but possibly that also affects its performance in some way would be interesting to know. – cardamom Feb 07 '22 at 10:58