Home·Terminal commands

dd

Archives

Usage

dd if=<source> of=<target> bs=4M status=progress

Copies block for block, which is how an installer image gets written to a device; whatever you name in `of=` is overwritten from block zero with no confirmation and no way back, so confirm the device with lsblk immediately before pressing Enter, use `bs=4M` for speed and `status=progress` (Ctrl+T on macOS) to watch it.

Common flags

FlagMeaning
if=<file>Input file or device. Leaving it out reads stdin.
of=<file>Output. Whatever this names is overwritten from block zero, with no confirmation.
bs=4MBlock size. Too small and the copy crawls.
count=<n>Copy only n blocks.
status=progressShow progress (GNU). On macOS press Ctrl+T instead.
conv=fsyncFlush to the device before exiting, so the numbers mean something.
conv=notruncWrite in place without truncating the output file.

Examples

lsblk

Always confirm the device name immediately before the next command.

sudo dd if=ubuntu.iso of=/dev/sdb bs=4M status=progress conv=fsync

Write an installer image to a whole USB device (Linux).

diskutil unmountDisk /dev/disk4 && sudo dd if=ubuntu.iso of=/dev/rdisk4 bs=4m

On macOS the disk must be unmounted first, or dd fails with Resource busy; rdiskN is the fast raw path.

Bundling and compressing are separate jobs: tar bundles, gzip shrinks, and .tar.gz is both.

How to read this

  • Square brackets [ ] mark a part you may leave out.
  • An ellipsis … means you can list more than one.
  • Flags are case-sensitive — in some commands -r and -R do different things.

Questions

Q. What does dd do?

Copies block for block, which is how an installer image gets written to a device; whatever you name in `of=` is overwritten from block zero with no confirmation and no way back, so confirm the device with lsblk immediately before pressing Enter, use `bs=4M` for speed and `status=progress` (Ctrl+T on macOS) to watch it.

Q. How do I type it?

dd if=<source> of=<target> bs=4M status=progress — square brackets mark the parts you can leave out.

Q. How many flags are worth knowing?

7 are listed here; the full set is in man dd. This command sits under Archives.

Related commands

man page: man dd