الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

dd

Copy data block by block: make disk images, write ISO files to USB, create files of a fixed size, wipe or test disks.

المستوى
لينكس اليومي
المجموعة
الأقراص وأنظمة الملفات
يحتاج root
للتغييرات
الحزمة
coreutils

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

ماذا يفعل

dd if=INPUT of=OUTPUT bs=SIZE count=N reads blocks from the input and writes them to the output. It works on files and on raw devices (whole disks), so it can copy or destroy anything — people call it "disk destroyer" for a reason. Always check of=.

Options are written as name=value, not with dashes.

طريقة الكتابة

dd [OPERAND]...

الخيارات 15

الأكثر استخدامًا

if=FILE
Read from this file or device (default stdin).
of=FILE
Write to this file or device (default stdout).
bs=BYTES
Block size for read and write (like 1M, 4M).
count=N
Copy only N blocks.
ibs=BYTES
Read block size.
obs=BYTES
Write block size.
cbs=BYTES
Conversion block size.
skip=N, iseek=N
Skip N input blocks.
seek=N, oseek=N
Skip N output blocks.
conv=LIST
Conversions: notrunc, noerror, sync, sparse, fsync, fdatasync, excl, nocreat, ucase, lcase …
iflag=LIST
Input flags: fullblock, direct, nocache, skip_bytes, count_bytes …
oflag=LIST
Output flags: direct, sync, dsync, append, nocache, seek_bytes …
status=LEVEL
none, noxfer or progress (show progress).
--help
Show help.
--version
Show the version.

أمثلة 11

$ مستخدم عادي# بصلاحية root (أو مع sudo)

  1. 1Create a file of 1 GiB with zeros

    dd if=/dev/zero of=/swapfile bs=1M count=1024

    Good for swap files (no holes).

  2. 2Write an ISO to a USB stick

    dd if=rhel-10.0-x86_64-dvd.iso of=/dev/sdc bs=4M status=progress oflag=sync

    /dev/sdc is the whole stick (no number). Check with lsblk first!

  3. 3Back up a partition to an image

    dd if=/dev/vdb1 of=/backup/vdb1.img bs=4M status=progress

    Unmount it first for a consistent copy.

  4. 4Back up the MBR (first 512 bytes)

    dd if=/dev/vda of=/root/mbr.bin bs=512 count=1

    Boot code and MBR table.

  5. 5Wipe the start of a disk

    dd if=/dev/zero of=/dev/vdb bs=1M count=10

    Removes partition table and signatures at the start (wipefs is cleaner).

  6. 6Test write speed

    dd if=/dev/zero of=/var/tmp/test bs=1M count=1024 oflag=direct status=progress

    direct skips the cache; delete the file after.

  7. 7Test read speed

    dd if=/var/tmp/test of=/dev/null bs=1M iflag=direct

    Real disk reads.

  8. 8A busy CPU process for labs

    dd if=/dev/zero of=/dev/null &

    Practice top, nice and kill.

  9. 9Random data file

    dd if=/dev/urandom of=random.bin bs=1M count=10

    Test files that do not compress.

  10. 10Copy a failing disk and go on after errors

    dd if=/dev/sdb of=/backup/sdb.img bs=64K conv=noerror,sync status=progress

    Bad blocks become zeros (ddrescue is better for this).

  11. 11Restore only the boot code

    dd if=/root/mbr.bin of=/dev/vda bs=446 count=1

    Restores only the boot code, not the partition table (446 bytes).

انتبه

  • of= on the wrong disk destroys it at once. There is no question and no undo.
  • Without status=progress dd prints nothing until it is done; send kill -USR1 PID for a status.

رموز الخروج

0 :: Done. 1 :: Error.