dd (Unix)

dd is a command-line utility for Unix, Plan 9, Inferno, and Unix-like operating systems and beyond, the primary purpose of which is to convert and copy files.

As a result, dd can be used for tasks such as backing up the boot sector of a hard drive, and obtaining a fixed amount of random data.

According to Dennis Ritchie, the name is an allusion to the DD statement found in IBM's Job Control Language (JCL),[3][4] in which it is an abbreviation for "Data Definition".

[14] dd is sometimes humorously called "Disk Destroyer", due to its drive-erasing capabilities involving typos.

A block is a unit measuring the number of bytes that are read, written, or converted at one time.

[8]: OPERANDS The value provided for block size options is interpreted as a decimal (base 10) integer number of bytes.

[8]: OPERANDS  Implementation differ on the additional suffixes they support: (Free) BSD uses lowercase m (mebibytes), g (gibibytes), and so on for tebibytes, exbibytes, pebibytes, zebibytes, and yobibytes,[16] while GNU uses M and G for the same units, with kB, MB, and GB used for their SI unit counterparts (kilobytes).

Additionally, some implementations understand the x character as a multiplication operator for both block size and count parameters.

To make them portable, replace e.g. bs=64M with the shell arithmetic expression bs=$((64*1024*1024)) or bs=$((64 << 20)) (written equivalently with a bit shift).

The example above can also be used to back up and restore any region of a device to a file, such as a master boot record.

When compared to the data modification example above, notrunc conversion option is not required as it has no effect when the dd's output file is a block device.

[citation needed] On Linux machines it is accessible via the hdparm command's --security-erase-enhanced option.

The shred program offers multiple overwrites, as well as more secure deletion of individual files.

dd is a good fit with this job with its flexible skipping (seek) and other low-level settings.

The single block size also limits the granularity of the recovery, as a trade-off has to be made: either use a small one for more data recovered or use a large one for speed.

To make drive benchmark test and analyze the sequential (and usually single-threaded) system read and write performance for 1024-byte blocks: To make a file of 100 random bytes using the kernel random driver: To convert a file to uppercase: Being a program mainly designed as a filter, dd normally does not provide any progress indication.

The following one-liner results in continuous output of progress every 10 seconds until the transfer is finished, when dd-pid is replaced by the process-id of dd: Newer versions of GNU dd support the status=progress option, which enables periodic printing of transfer statistics to stderr.

[24] dcfldd is a fork of GNU dd that is an enhanced version developed by Nick Harbour, who at the time was working for the United States' Department of Defense Computer Forensics Lab.

[28] dc3dd is another fork of GNU dd from the United States Department of Defense Cyber Crime Center (DC3).