How to do it...

The dd command is mainly used for converting and copying files. The if parameter stands for input-file and is a source. of stands for output-file and is a source where we want to paste data.

  1. Run the following command to copy the contents of one file to another:
# create a file 01.txt and add some content in that file.# create another file 02.txt and add some content in that file.$ dd if=/home/student/work/01.txt of=/home/student/work/02.txt bs=512 count=1
  1. Run the following command to take a backup of the partition or the hard disk:
$ sudo dd if=/dev/sda2 of=/home/student/hdbackup.img
  1. The dd command is also used to erase all of the contents of the disk. Run the following command to delete the contents:
$ sudo dd if=/home/student/work/1.sh ...

Get Bash Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.