Introduction to Linux DD commands __linux

Source: Internet
Author: User

1. Introduction

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.


2. Option

If=file Enter the filename, which defaults to standard input.
Of=file output file name, default to standard output.
Ibs=bytes reads bytes bytes at a time (that is, a block size of bytes bytes).
Obs=bytes Write bytes bytes at a time (that is, a block size of bytes bytes).
Bs=bytes also sets the size of the read-write block to be bytes, which can replace IBS and OBS.
Cbs=bytes converts bytes bytes at a time, that is, the size of the conversion buffer.
Skip=blocks skips blocks blocks from the start of the input file before copying.
Seek=blocks skips blocks blocks from the beginning of the output file before copying. (usually only works if the output file is disk or tape)
Count=blocks copies only blocks blocks, and the block size equals the number of bytes specified by IBS.
Conv=conversion[,conversion ...] Converts the file with the specified parameters.
Conversion parameters:
ASCII conversion EBCDIC to ASCII.
EBCDIC converts ASCII to EBCDIC.
IBM converts ASCII to alternate EBCDIC.
Block converts each line into a record length of CBS, with less than a space filled in.
Unblock 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 an odd number of bytes, the last byte is simply copied (since there are nothing to-swap it with) .
NoError does not stop when an error occurs.
Notrunc does not truncate the output file.
Sync fills each input block to IBS bytes, and the insufficient part is padded with empty (NUL) characters.


3. Example

Example one:

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.


Example two:

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


Reference: Baidu Encyclopedia

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.