I think I only used the dd command less than ten times in my Linux sysadmin life. So, I decided to put together a simple dd Command Tutorial for Sysadmins. But, first I had to brew my favorite Caturra coffee variety and check out their Specialty Coffee news section.
What is dd?
dd is a low-level copying tool in Linux/UNIX. Unlike cp, it works at the raw byte level, meaning it can copy anything: files, partitions, disks, even memory.
This makes it invaluable for backups, recovery, cloning, and troubleshooting.
Basic Syntax
dd if=<input> of=<output> [options]if= → input file/device (source)of= → output file/device (destination)bs= → block size (how much data to read/write at once)count= → how many blocks to copystatus=progress → show progress bar (modern feature)
Real-Life Use Cases for Sysadmins
Backup the first 512 bytes (bootloader + partition table):
sudo dd if=/dev/sda of=mbr_backup.img bs=512 count=1Restore it if corrupted:
sudo dd if=mbr_backup.img of=/dev/sda bs=512 count=1Clone a Full Disk
sudo dd if=/dev/sda of=/dev/sdb bs=4M status=progressMakes /dev/sdb a bootable copy of /dev/sda.
Useful for migrations or duplicating lab servers.
Create a Disk Image
sudo dd if=/dev/sda of=disk_backup.img bs=4M status=progressCreates an image file (disk_backup.img) you can compress or transfer.
Write an ISO to USB
sudo dd if=ubuntu.iso of=/dev/sdb bs=4M status=progress oflag=syncCommon method for creating bootable USB drives.
Wipe a Disk Securely
Overwrite a disk with zeros:
sudo dd if=/dev/zero of=/dev/sdb bs=1M status=progressOverwrite with random data:
sudo dd if=/dev/urandom of=/dev/sdb bs=1M status=progressCareful: This destroys all data on the target disk.
Performance Testing (Disk Speed)
Write test:
dd if=/dev/zero of=testfile bs=1G count=1 oflag=dsyncRead test:
dd if=testfile of=/dev/null bs=1G count=1Partial File Copy (Skip & Limit)
Copy the first 100MB of a file:
dd if=bigfile.iso of=sample.iso bs=1M count=100Skip first 50MB and copy the next 100MB:
dd if=bigfile.iso of=part.iso bs=1M skip=50 count=100Create Swap File
sudo dd if=/dev/zero of=/swapfile bs=1M count=2048
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfileMakes a 2GB swap file.
Safety Tips
Always double-check if= and of= before pressing Enter.
Use lsblk or fdisk -l to confirm disk names.
Practice with small files before using real disks.
Quick Reference Cheatsheet
- Backup MBR:
dd if=/dev/sda of=mbr.img bs=512 count=1 - Clone disk:
dd if=/dev/sda of=/dev/sdb bs=4M status=progress - ISO → USB:
dd if=linux.iso of=/dev/sdb bs=4M status=progress - Wipe disk:
dd if=/dev/zero of=/dev/sdb bs=1M status=progress - Create swap:
dd if=/dev/zero of=/swapfile bs=1M count=2048
Contact me if you have any questions. If you like my work consider supporting me by shopping one of my coffee mugs and T-Shirt designs using my Shop here.

