dd is a common Unix program whose primary purpose is the low-level copying and conversion of raw data. You can use this command backup whole hard drives, create a large file filled with only zeros, create and modify image files at specific points, and even do conversions to upper case. dd Command can strip headers, write middle of the disk, extracts parts of the binary files and it can be used by the Linux kernel makefiles to make boot images. dd capable to copy and convert magnetic tape formats, convert between ASCII and EBCDIC, Swap bytes.
Syntax: dd if=infput file of=outputfile bx=byte size
Here will create fixed 10 MB file using dd command
[root@localhost ~]# dd if=/dev/zero of=testfile1MB bs=10485760 count=1
1+0 records in
1+0 records out
10485760 bytes (10 MB) copied, 0.253435 seconds, 41.4 MB/s
In above example “if” meaning inputfile (reading) and “of” meaning output file(where the data has to write), “bs” is a byte size. By default linux will take byte size (bs) as 512 bytes if don’t specify the bs option.
Yes. dd command can be used to wipe the data
Note: While executing this command be careful.
[root@localhost ~]# dd if=/dev/zero of=/root/anaconda bs=1024 count=5
5+0 records in
5+0 records out
5120 bytes (5.1 kB) copied, 0.00161641 seconds, 3.2 MB/s
In the above example we are writing null to the /root/anaconda file. Above command will overwrite all file content to null.
Similar way you can wipe the entire disk/partition and MBR content by executing following command.
[root@localhost ~]# dd if=/dev/zero of=/dev/
(where name of the disk/name of the partition)
Note: Master Boot Record resides first sector of the disk that is 512. In 512 bytes 446 byte is used for storing Boot loader information. Again Careful while trying this.
[root@localhost ~]# dd if=/dev/zero of=/dev/hda bs=446
Or you can also use urandom file.
# dd if=/dev/urandom of=/dev/hdc