System and processes
The dd command
Copies data block by block: clones disks and creates exact-size files.
Most useful options
bs= <bytes>Bytes per read and write block (default 512). Overrides ibs and obscount= <N>Copies only N input blocks and then stopsskip= <N>Skips N input blocks before starting to copyseek= <N>Positions the output N blocks in before writingconv= <conversiones>Comma-separated conversions. notrunc does not truncate the output; noerror continues after read errorsstatus= <nivel>How much information goes to stderr: none, noxfer or progress for periodic statisticsiflag= <flags>Read flags, such as direct, fullblock or nocacheoflag= <flags>Write flags, such as direct, dsync or appendCopy-ready examples
$ printf 'datos\n' > a.txt && dd if=a.txt of=b.txtcopies one file to another. At the end it shows the summary of copied blocks.$ dd if=/dev/zero of=ceros.bin bs=1 count=4creates a file of 4 zero bytes.$ dd if=/dev/urandom of=aleatorio.bin bs=1M count=1 status=noneone megabyte of random data, with no statistics on screen.$ dd if=/dev/zero of=disco.img bs=1M count=100 status=progresscreates a 100 MiB file showing progress.$ sudo dd if=imagen.iso of=/dev/sdX bs=4M status=progressWARNING: writes over the whole device and erases its content. /dev/sdX is a placeholder: confirm the real name with lsblk before running anything.You can try them in the browser terminal: it does not touch your computer.
Common errors
| Message | Cause | Fix |
|---|---|---|
| dd: failed to open 'noexiste': No such file or directory | The input file does not exist or the name is misspelled. | List the folder with ls and copy the exact name into if=. |
| dd: invalid number: '0' | You passed a value dd does not accept, such as bs=0. The block size has to be greater than zero. | Use a valid size, such as bs=1M or bs=512. |
Typical mistakes
- With if= and of= it is easy to swap them or point at a disk as the target: always check of= before pressing Enter.
- By default the output is truncated when it starts, so its previous content disappears. To write without truncating, use conv=notrunc.
- By default dd only shows the final summary. With status=progress you see periodic statistics.
- With bs=1 every byte is a separate read and the copy is very slow: for large files, use a bs of 1M or similar.
Differences from similar commands
- cp: copies whole files by name. dd copies bytes or blocks and can skip positions or copy devices.
- cat: concatenates and shows content. dd controls the block size, how many blocks it copies and from which position.
- lsblk: shows which devices exist. dd uses them as source or target without checking anything for you.
Security
dd does not ask for confirmation. Writing to the wrong device erases its data with no way back: always check the of= and the disk name.
FAQ
What is dd actually used for?
To clone disks, create bootable USB sticks or generate test files of an exact size. To copy ordinary files, cp is safer.
Why does dd show nothing while it copies?
It only shows the final summary. With status=progress you see periodic statistics; you can also send the USR1 signal to the process, which the manual documents to print them.
Does dd delete the target file?
It does not delete it, but it truncates it at the start: the previous content disappears. With conv=notrunc the rest of the file is kept.
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course