Table of Contents

Linux Commands Cheat Sheet

dd - How to use dd command in Linux



Create File

/dev/zero

Using /dev/zero is very fast.

dd if=/dev/zero of=test_10M   bs=1M count=10
dd if=/dev/zero of=test_100M  bs=1M count=100
dd if=/dev/zero of=test_1G    bs=1M count=1000
dd if=/dev/zero of=test_2G    bs=1M count=2000
dd if=/dev/zero of=test_5G    bs=1M count=5000
dd if=/dev/zero of=test_10G   bs=1M count=10000


/dev/urandom

Using /dev/urandom is very slow.

dd if=/dev/urandom of=test_10M   bs=1M count=10
dd if=/dev/urandom of=test_100M  bs=1M count=100
dd if=/dev/urandom of=test_1G    bs=1M count=1000
dd if=/dev/urandom of=test_2G    bs=1M count=2000
dd if=/dev/urandom of=test_5G    bs=1M count=5000
dd if=/dev/urandom of=test_1G    bs=1M count=10000


sparse file

write zero

dd if=/dev/zero of=temp.bin bs=1 count=0 seek=1G


Example

# dd if=/dev/zero of=test_100M   bs=1M count=100
100+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 0.497892 s, 211 MB/s
# dd if=/dev/urandom of=test_100M   bs=1M count=100
100+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 8.94563 s, 11.7 MB/s





Linux Commands Cheat Sheet