🖥️dd

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the dd command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ██████╗ ██████╗ 
#                ██╔══██╗██╔══██╗
#                ██║  ██║██║  ██║
#                ██║  ██║██║  ██║
#                ██████╔╝██████╔╝
#                ╚═════╝ ╚═════╝ 
                                
                               
# Read from {/dev/urandom} 2*512 Bytes and put it into {/tmp/test.txt}
# Note: At the first iteration, we read 512 Bytes.
# Note: At the second iteration, we read 512 Bytes.
dd if=/dev/urandom of=/tmp/test.txt count=512 bs=2

# Watch the progress of 'dd'
dd if=/dev/zero of=/dev/null bs=4KB &; export dd_pid=`pgrep '^dd'`; while [[ -d /proc/$dd_pid ]]; do kill -USR1 $dd_pid && sleep 1 && clear; done

# Watch the progress of 'dd' with `pv` and `dialog` (apt-get install pv dialog)
(pv -n /dev/zero | dd of=/dev/null bs=128M conv=notrunc,noerror) 2>&1 | dialog --gauge "Running dd command (cloning), please wait..." 10 70 0

# Watch the progress of 'dd' with `pv` and `zenity` (apt-get install pv zenity)
(pv -n /dev/zero | dd of=/dev/null bs=128M conv=notrunc,noerror) 2>&1 | zenity --title 'Running dd command (cloning), please wait...' --progress

# Watch the progress of 'dd' with the built-in `progress` functionality (introduced in coreutils v8.24)
dd if=/dev/zero of=/dev/null bs=128M status=progress

# DD with "graphical" return
dcfldd if=/dev/zero of=/dev/null bs=500K

# This will output the sound from your microphone port to the ssh target computer's speaker port. The sound quality is very bad, so you will hear a lot of hissing.
dd if=/dev/dsp | ssh -c arcfour -C username@host dd of=/dev/dsp

# Show current progress without interruption (USR1)
dd if=/dev/zero of=/dev/null & pid=$!
kill -USR1 $pid

#==============================#
# CMD DD - DiskDump
#==============================##==============================#
dd if=/dev/random of=randomdata iflag=fullblock bs=1k count=1 
# Random chiptune from bash. Try using dd for comparison.

dd if=/dev/hda of=/dev/hdb
# device to device

dd if=/dev/hda of=/mnt/backup/hda.img
#

dd if=/dev/sda of=sda.image bs=512 count=1
#

dd if=sda.image of=/dev/sda
# image to device

dd if=/dev/null of=/dev/sda1 bs=$BLOCKSIZE seek=$OFFSET count=1 oflag=direct,dsync
#

dd status=progress…
# Oh no, it is starting.

dd if=/dev/cdrom of=image.iso ; mkdir CDroot ; mount -o loop image.iso CDroot ; cd CDroot
# Mount a CDROM disc from its ISO image file.

dd if=/dev/random of=randomdata iflag=fullblock bs=1k count=1 for comparison.
# Random chiptune from bash. Try using 

dd if=kali-linux-1.0.8-amd64.iso of=/dev/sdb bs=1M

dd if=/dev/hda | ssh rechner2 dd of=rechner1-hda.img
# dd over ssh tunnel

ssh root@r-xyz dd if=/dev/sda | dd of=r-xyz.image
# dd over ssh tunnel

dd if=/dev/mem bs=1k skip=768 count=256 2>/dev/null | strings -n 8 
# Read the BIOS on PC hardware. Thanks @Fr33Wor1d, better late than never

dd if=/dev/zero of=/tmp/output.img bs=8k count=256k conv=fdatasync; rm -rf /tmp/output.img
# The next gem in the list is – how to check disk write speed? Well one liner dd command script serves the purpose.
# Explanation of commands and switches.
#    dd – Convert and Copy a file
#    if=/dev/zero – Read the file and not stdin
#    of=/tmp/output.img – Write to file and not stdout
#    bs – Read and Write maximum upto M bytes, at one time
#    count – Copy N input block
#    conv – Convert the file as per comma separated symbol list.
#    rm – Removes files and folder
#    -rf – (-r) removes directories and contents recursively and (-f) Force the removal without prompt.

dd if=/dev/random of=dont-run-this.bin bs=128 count=$RANDOM ; chmod a+x dont-run-this.bin 
#Randomware #TyposIMake

dd if=/dev/urandom => Use random data grep -a -o -P "[\x01-\xD0]" 
=> Keep only ascii tr -d $'\n' 
=> and remove newlines dd of=art.jpg bs=1 seek=$h count=$r 
=> and write it in the file, starting at the half ($h) and for remainder ($r) bytes

# How to remotely backup a disk in Linux - This command let the user make a backup of the disk 'dev/hda' towards the remote server at IP 10.0.1.26.
# So, the procedure is: locally launch this command, which connects to 10.0.1.26 via ssh and create a file named backup.img on remote 10.0.1.26 server
dd if=/dev/hda | ssh [email protected] "(cat >/home/cri/backup.img)"   

# How to remotely backup a disk in Linux
# This command let the user make a backup of the disk 'dev/hda' towards the remote server at IP 10.0.1.26. So, the procedure is: locally launch this command, which connects to 10.0.1.26 via ssh and create a file named backup.img on remote 10.0.1.26 server
dd if=/dev/hda | ssh [email protected] "(cat >/home/cri/backup.img)"     

dd if=/dev/sdc bs=1M skip=25k | strings -n12 
# Start searching for text data, but skip the first 25GB (25k of 1MB blocks) of the drive.

dd if=/dev/cdrom of=image.iso ; mkdir CDroot ; mount -o loop image.iso CDroot ; cd CDroot 
# Mount a CDROM disc from its ISO image file.

dd if=/home/kozanoglu/Downloads/XenServer-7.2.0-install-cd.iso | pv --eta --size 721420288 --progress --bytes --rate --wait > /dev/sdb
# iso to USB with dd and show progress status need package: pv apt-get install pv get the iso size in byte with ls -l install-cd.iso /dev/sdb is your USB Device (without partitionNr.)

dd if=/dev/xvdf bs=1M skip=800 | tr -d '\000' | less 
# The dd command has a skip option that can help you start your output later in the input. In this case, 800MB in, avoiding unnecessary transfer of the first 800MB. The tr -d '\000' removes all the nulls.

# Faster disk imaging with dd
dd if=/dev/sda bs=$(hdparm -i /dev/sda | grep BuffSize | cut -d ' ' -f 3 | tr [:lower:] [:upper:] | tr -d BUFFSIZE=,) conv=noerror | dd of=image.dd conv=noerror

# Explanation: GNU dd (disk dump) copies any block device to another block device or file. It's really useful for disk cloning, but its usual invocation isn't as fast as it could be. These settings, or settings like them, often improve copying speed by more than double.
    # Piping the input of dd into the output of another instance seems to always improve copying speed.
    # /dev/sda refers to your input device, which may vary. Check yours with fdisk -l.
    # image.dd refers to the copy stored in the current working directory. You can also use another block device, such as /dev/sdb. WARNING! Be sure you know what you set the output file to! A mistake here could do irreparable damage to your system.
    # The entire hdparm subshell sets dd's input block size to the buffer size of the source medium. This also usually improves copy speed, but may need adjustment (see # Limitations:  below).
    # conv=noerror tells dd to ignore read errors.
    # Check dd's progress with: kill -USR1 $(pidof dd)
# Limitations: The hdparm subshell is not appropriate for block devices without buffers, like flash drives. Try block sizes from 512 bytes to 1 or 2MiB to get the best speed. dd usually requires root privileges to run, because it is very powerful and dangerous, and will not prompt when overwriting!. If you are not careful where dd outputs, you may permanently destroy all or part of your system. Use with care; double-check all parameters, especially the of file/device!

#==============================##==============================#
# CMD dd						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░