Navigation and files

Command dd

Low-level copying of data and disk images

Linux · Bash examples · commands run on the selected server

When to use dd

Use dd when you need byte-oriented copying with explicit block sizes and counts. Ordinary file copies rarely require it. Its output path is opened for writing, so verify both paths before starting.

Syntax

dd [OPERAND=VALUE]…

Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.

Common options and arguments

if=FILE
Data source; without it, standard input is read.
of=FILE
Destination; defaults to standard output.
bs=SIZE
Block size; status=progress shows the progress of copying.

Usage examples

Create a small test file

dd if=/dev/zero of=./terminalus-demo.bin bs=1M count=4 status=progress

This creates a four-mebibyte test file in the current directory, replacing an existing file of the same name.

Read the first blocks of a file

dd if=./terminalus-demo.bin of=./terminalus-head.bin bs=1K count=2

Only the first two kibibytes are copied into a separate output file.

Check file read

dd if=./terminalus-demo.bin of=/dev/null bs=1M status=progress

The test file is read and discarded; this checks a read path without creating another copy.

Notes and limitations

  • Check the of= destination: dd overwrites it without prompting. Never use a device containing live data as the example destination.
  • if= and of= are dd operands, not short options preceded by a hyphen.

Common questions and troubleshooting

Why is dd dangerous with a device path?

An incorrect output device can overwrite a filesystem or partition table immediately. These examples deliberately use ordinary test files instead of disks.

Why is there no progress display?

The progress option is implementation-dependent. Check the installed manual; completion statistics and the exit status are separate from periodic progress output.

Further help

Options vary by version and distribution. Check the installed documentation with this command: man dd.