Get the App
SLTechnology News&Howtos  ›  Servers  › 

The usage of the Linux command dd

Shulou Source: shulou.com Published: 2022-06-01 12:30:54 10月18日 Update

This article mainly introduces "the usage of Linux command dd". In daily operation, I believe many people have doubts about the usage of Linux command dd. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "the usage of Linux command dd"! Next, please follow the editor to study!

Dd is a very useful command under Linux/UNIX, which is used to copy a file with a block of the specified size and perform the specified conversion at the same time.

The main options for dd:

If the place of the specified number ends with the following characters multiplied by the corresponding number:

Baked 512, cased 1, kappa 1024, walled 2, xm=number m

If=file

Enter the file name, which defaults to standard input.

Of=file

Output file name, which defaults to standard output.

Ibs=bytes

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

Obs=bytes

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

Bs=bytes

At the same time, the size of the read and write block is set to bytes, which can replace ibs and obs.

Cbs=bytes

Convert bytes bytes at a time, that is, convert the buffer size.

Skip=blocks

Skip blocks blocks from the beginning of the input file before you start copying.

Seek=blocks

Skip blocks blocks from the beginning of the output file before you start copying. (usually valid only if the output file is a disk or tape)

Count=blocks

Only blocks blocks are copied, and the block size is equal to the number of bytes specified by ibs.

Conv=conversion [, conversion...]

Converts the file with the specified parameters.

Conversion parameters:

Ascii converts EBCDIC to ASCII.

Ebcdic converts ASCII to EBCDIC.

Ibm converts ASCII to alternate EBCDIC.

Block converts each line to a record of length cbs, with gaps filled in.

Unblock

Make the length of each line cbs, and fill the insufficient parts with blanks.

Lcase converts uppercase characters to lowercase characters.

Ucase converts lowercase characters to uppercase characters.

Swab swaps each pair of bytes entered. Unlike the

Unix dd, this works when an odd number of

Bytes are read. If the input file contains

An odd number of bytes, the last byte is

Simply copied (since there is nothing to

Swap it with).

Noerror

Don't stop when something goes wrong.

Notrunc

The output file is not truncated.

Sync fills each input block into ibs bytes, and the deficiency is filled with NUL characters.

Because the dd command allows binary reading and writing, it is particularly suitable for input / output on raw physical devices. For example, you can use the following command to create an image 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 tools. Another example is to save the first 512 bytes of the first hard disk as a file:

Dd if=/dev/hda of=disk.mbr bs=512 count=1

At this point, the study of "the usage of the Linux command dd" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: File byte command size character input output learning copy part line parameter at the same time uppercase lowercase beginning number file name more standard Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Redmi Apple OPPO Reno Shulou Tech Info