dd: command not found

The dd command copies and converts files to enable them to be transferred from one type of media to another. The dd command has various operands, or actions, to perform. If you need to clone a device, you can use dd. For instance, you can use it to write the contents of an optical drive to an ISO file or to make an exact copy of one disk to another. The dd command has two mandatory options. Use if= to specify the input device. Next, by using of=, you specify what output device to use. For optimal efficiency, it is a good idea to add the parameter bs=4096. Most file systems work with 4K blocks, and this option makes sure that the copy is made block by block instead of byte by byte. It will offer you a performance that is about four times better than without using the bs= option.

  • if={file name}: Specify the file from which data will be read.
  • of={file name}: Specify the file to which data will be written.
  • bs={bytes}: Specify the total block size to read and write, in bytes. Bytes can also be formatted in a more human-friendly way, such as 50M to specify 50 megabytes and 10G to specify 10 gigabytes.
  • count={count}: Specify the number of blocks to be written to the output file from the input file.
  • status={level}: Specify the level of information to print to standard error.

Syntax

The syntax of the dd command is:

# dd [options] [operands]

If you encounter the below error while running the dd command:

dd: command not found

you may try installing the below package as per your choice of distribution:

Distribution Command
OS X brew install coreutils
Debian apt-get install coreutils
Ubuntu apt-get install coreutils
Alpine apk add coreutils
Arch Linux pacman -S coreutils
Kali Linux apt-get install coreutils
CentOS yum install coreutils
Fedora dnf install coreutils
Raspbian apt-get install coreutils

dd Command Examples in Linux

1. Make a bootable USB drive from an isohybrid file (such like `archlinux-xxx.iso`) and show the progress:

# dd if=file.iso of=/dev/usb_drive status=progress

2. Clone a drive to another drive with 4 MiB block, ignore error and show progress:

# dd if=/dev/source_drive of=/dev/dest_drive bs=4M conv=noerror status=progress

3. Generate a file of 100 random bytes by using kernel random driver:

# dd if=/dev/urandom of=random_file bs=100 count=1

4. Benchmark the write performance of a disk:

# dd if=/dev/zero of=file_1GB bs=1024 count=1000000

5. Generate a system backup into an IMG file and show the progress:

# dd if=/dev/drive_device of=path/to/file.img status=progress

6. Restore a drive from an IMG file and show the progress:

# dd if=path/to/file.img of=/dev/drive_device status=progress

7. Check progress of an ongoing dd operation (Run this command from another shell):

# kill -USR1 $(pgrep ^dd)

8. You can use dd to perform a full backup of a storage partition. The following example copies data from /dev/sda1 to /dev/sdb2:

# dd if=/dev/sda of=/dev/sdb

9. Using dd, you can also create an image of a drive and then clone a second drive with it:

# dd if=/dev/sda of=drive_image.iso
# dd if=drive_image.iso of=/dev/sdb

Note

The dd command is very powerful. Though its name derives from “data definition,” it is sometimes called “destroy disk” because users often mistype either the if or of specification. Always double-check your input and output specifications before pressing ENTER!

Related Post