Linux

dd

Convert and copy files.

#linux #disk #backup

Basic Usage

Copy one file to another.

dd if=[input_file] of=[output_file]

if: Input file (read from). of: Output file (write to).


Show Progress

Show progress bar while copying.

dd if=[input_file] of=[output_file] status=progress

Create Bootable USB

Write an ISO image to a USB drive.

dd if=image.iso of=[output_file] bs=4M status=progress && sync

Warning: This will destroy all data on the target drive /dev/sdX.


Backup Disk to Image

Create a compressed backup of a disk.

dd if=[input_file] | gzip > [output_file].gz

Restore Disk from Image

Restore a compressed backup to a disk.

gzip -dc [output_file].gz | dd of=[input_file]

Zero Fill Disk

Wipe a disk by writing zeros to it.

dd if=/dev/zero of=[input_file] bs=4M status=progress

Random Fill Disk

Wipe a disk by writing random data to it (more secure).

dd if=/dev/urandom of=[input_file] bs=4M status=progress