A detailed explanation of DD command usage in Linux

Source: Internet
Author: User
Tags manual insert lowercase

Use rights: All user dd This instruction is defined in manual as convert and copy a file

How to use: DD [option]

If you want to see manual online, try it: DD--help or info DD

If you want to see how this version is: DD--version

Input or output DD If=[stdin] of=[stdout]

Force input or output SIZE to how many bytes Bs:dd-ibs=[byte]-obs=[size]

How many Bytes do you have to force at a time cbs=bytes

Skip a paragraph before outputting seek=blocks

Skip a paragraph before entering skip=blocks

Of course you can use this to easily copy discs (Note that your disc is a standard iso9660 format to do so!) )

DD If=/dev/cdrom Of=cdrom.iso

The contents of the if and after are adjusted according to your requirements.

Then give the system the instructions to burn:

Cdrecord-v Cdrom.iso

This is not about Cdrecord, so the instructions above are the simplest but not necessarily compatible with your hardware environment ...

Function: Copies the specified input file to the specified output file, and can be converted to format during the copy process. You can use this command to realize the function of the diskcopy command under DOS. First use the DD command to write the data on the floppy disk as a storage file, and then put the storage file into the second floppy disk, complete the function of diskcopy. It should be noted that the storage files on the hard disk should be removed with the RM command. The system defaults to using standard input files and standard output files.

Syntax: DD [Options]

if = input file (or device name).

of = output file (or device name).

ibs = Bytes Read bytes bytes at a time, that is, the number of bytes read into the buffer.

Skip = Blocks skips the Ibs*blocks block at the beginning of the read buffer.

Obs = bytes Writes bytes bytes At a time, that is, the number of bytes written to the buffer.

BS = bytes Sets the number of bytes in the read/write buffer (equal to setting IBS and OBS).

CBS = byte convert bytes byte at a time.

Count=blocks only copies the input blocks blocks.

Conv = ASCII converts EBCDIC code to Ascil code.

Conv = EBCDIC converts ascil code to EBCDIC code.

CONV = IBM converts ascil code to alternate EBCDIC code.

CONV = block Converts a bit of change to a fixed character.

CONV = Ublock Converts a fixed bit into a change bit.

CONV = UCase converts letters from lowercase to uppercase.

CONV = LCase converts letters from uppercase to lowercase.

CONV = Notrunc does not truncate the output file.

CONV = Swab Exchange Each pair of input bytes.

CONV = NoError does not stop processing when an error occurs.

Conv = sync the size of each input record to the size of the IBS (filled with nul).

Example 1: To copy the contents of a floppy disk to another floppy disk, use/tmp as a temporary storage area. Insert the source disk into the drive and enter the following command:

$ dd if =/dev/fd0 of =/tmp/tmpfile

After the copy is complete, remove the source disk from the drive, insert the target disk, and enter the command:

$ dd if =/tmp/tmpfile of =/dev/fd0

After the floppy copy is complete, you should delete the temporary file:

$ rm/tmp/tmpfile

Example 2: Write the net.i file to the floppy disk and set the number of read/write buffers.

(Note: The contents of the floppy disk will be completely overwritten)

$ dd if = net.i of =/dev/fd0 bs = 16384

Example 3: Copy the file sfile to the file Dfile.

$ dd If=sfile Of=dfile


This article URL address: http://www.bianceng.cn/OS/Linux/201410/45507.htm

DD is a very useful command under Linux/unix to copy a file with a block of a specified size and to make a specified conversion at the same time as a copy.

Main options for DD:

The place where the number is specified is multiplied by the corresponding number at the end of the following character:

b=512, C=1, k=1024, w=2, Xm=number m


Enter a filename, which defaults to standard input.


The output file name, which defaults to standard output.


Read bytes bytes at a time (that is, a block size of bytes bytes).


Write bytes bytes at a time (that is, a block size of bytes bytes).


At the same time, the size of the read-write block is bytes, which can replace IBS and OBS.


Converts bytes bytes at a time, that is, the size of the conversion buffer.


Skips blocks blocks from the start of the input file before copying.


Skips blocks blocks from the start of the output file before copying. (usually only works if the output file is disk or tape)


Copies only blocks blocks, and the block size equals the number of bytes specified by IBS.

Conv=conversion[,conversion ...]

Converts a file with the specified parameters.

Conversion parameters:

ASCII conversion EBCDIC to ASCII.


IBM converts ASCII to alternate EBCDIC.

Block converts each line into a record length of CBS, with less than a space filled in.


The length of each row is CBS, and the less part is filled with spaces.

LCase converts uppercase characters to lowercase characters.

UCase converts lowercase characters to uppercase characters.

Swab exchange input for each pair of bytes. Unlike the

Unix DD, this works at an odd number of

Bytes are read. If the input file contains

A odd number of bytes, the last byte is

Simply copied (since there is no to

Swap it with).


Do not stop when an error occurs.


The output file is not truncated.

Sync fills each input block to IBS bytes, and the insufficient part is padded with empty (NUL) characters.

Because the DD command allows binary access to read and write, it is particularly suitable for input/output on raw physical devices. For example, you can use the following command to create a mirrored file for a floppy disk:

DD if=/dev/fd0 of=disk.img bs=1440k

Interestingly, this image file can be read by hd-copy, WinImage and other tool software. If you save the first 512 bytes of your hard drive as a single file:

DD If=/dev/hda of=disk.mbr bs=512 count=1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.