multiple ways to run dd command with its examples

  • About dd : To convert and copy the olds
  • It comes from “coreutils-8.4-9.el6.i686” package.
  • Path: /bin/dd

Examples:

1. To copy a file

$ dd if=old.txt of=old.txt

2. To read and write specified bytes of a file at a time

$ dd bs=1024 if=old.txt of=old.txt

3. To convert a file to a specified format

$ dd bs=1024 if=old.txt of=new.txt conv=ascii (from EBCDIC to ASCII)
$ dd bs=1024 if=old.txt of=new.txt conv=ebcdic (from ASCII to EBCDIC)
$ dd bs=1024 if=old.txt of=new.txt conv=ibm (from ASCII to alternate EBCDIC)
$ dd bs=1024 if=old.txt of=new.txt conv=block    (pad oldline-terminated records with spaces to cbs-size)
$ dd bs=1024 if=old.txt of=new.txt conv=unblock (replace trailing spaces in cbs-size records with oldline)
$ dd bs=1024 if=old.txt of=new.txt conv=lcase  (change upper case to lower case)
$ dd bs=1024 if=old.txt of=new.txt conv=excl  (fail if the output old already exists)
$ dd bs=1024 if=old.txt of=new.txt conv=notrunc   (do not truncate the output old)
$ dd bs=1024 if=old.txt of=new.txt conv=ucase    (change lower case to upper case)
$ dd bs=1024 if=old.txt of=new.txt conv=swab     (swap every pair of input bytes)
$ dd bs=1024 if=old.txt of=new.txt conv=noerror  (continue after read errors)
$ dd bs=1024 if=old.txt of=new.txt conv=sync    (pad  every  input  block  with  NULs to ibs-size)
$ dd bs=1024 if=old.txt of=new.txt conv=fdatasync  (physically write output old data before finishing)
$ dd bs=1024 if=old.txt of=new.txt conv=fsync  (likewise, but also write metadata)

4. To copy only specified number of blocks

$ dd count=1024 if=old.txt of=new.txt

5. To copy a file with specifying a flag

$ dd if=old.txt of=new.txt oflag=append
$ dd if=old.txt iflag=directory of=new.txt oflag=directory
$ dd if=old.txt iflag=noatime of=new.txt oflag=append

6. To convert specified bytes at a time

$ dd cbs=1024 if=old.txt of=new.txt

7. To read specified number of bytes at a time

$ dd ibs=1024 if=old.txt of=new.txt

8. To write specified number of bytes at a time

$ dd obs=1024 if=old.txt of=new.txt

9. To skip specified number of blocks at start of o/p

$ dd seek=1024 if=old.txt of=new.txt

10. To skip specified number of blocks at start of i/p

$ dd skip=1024 if=old.txt of=new.txt

11. To suppress the transfer statistics

$ dd status=noxfer if=old.txt of=new.txt

Cocktail Examples

12. To erase the partition table for a device

$ dd if=/dev/zero of=/dev/sda4 bs=512 count=1

Leave a Reply

Your email address will not be published. Required fields are marked *