Simple dd usage

Source: Internet
Author: User

Copy the CPP file from windows to Linux, or from Linux to another Linux. CPP ,. H files often fail to be compiled. It is revealed that three more "things" are added at the beginning, such as tray357. We can't see VI, because it's not a character, and we don't know what the situation is. We inserted three bits of data. At this time, we can only copy the file again, through the graphic interface, or command DD.

Dd If = inputfile of = outputfile BS = bytes skip = skepbytes

1. Explanation of DD commands.

DD: Use a block of the specified size to copy an object and perform the specified conversion at the same time. Note: If a number is specified, it is multiplied by the corresponding number at the end of the following column: B = 512; C = 1; k = 1024; W = 2.

Parameters:

1. If = File Name: Enter the file name. The default value is standard input. Specifies the source file. <If = Input File>

2. Of = File Name: name of the output file. The default value is standard output. Specifies the target file. <Of = output file>

3. IBS = Bytes: Read bytes at a time, that is, specify the size of a block to bytes.

Obs = Bytes: outputs bytes at a time, that is, specify a block size as bytes.

BS = Bytes: set the size of the read/output block to bytes at the same time.

4. CBS = Bytes: bytes are converted at a time, that is, the size of the conversion buffer zone is specified.

5. Skip = blocks: the blocks are skipped from the beginning of the input file and then copied.

6. Seek = blocks: the blocks are skipped from the beginning of the output file and then copied.

Note: It is valid only when the output file is a disk or tape, that is, it is backed up to a disk or tape.

7. Count = blocks: copy only blocks. The block size is equal to the number of bytes specified by IBS.

8. Conv = Conversion: Convert the file with the specified parameter.

Block pad newline-terminated records with spaces to CBS-size

Unblock replace trailing spaces in CBS-size records with newline

Lcase: converts uppercase to lowercase.

Ucase: converts lowercase to uppercase.

Swab: swap each pair of input bytes

Noerror: Do not stop when an error occurs

Notrunc: the output file is not truncated.

Ii. Example

1. Back up/dev/HDB full data, compress it with gzip, and save it to the specified path.

Dd If =/dev/HDB | gzip>/root/image.gz

2. Restore the compressed backup file to the specified disk.

Gzip-DC/root/image.gz | dd OF =/dev/HDB

3. Copy the memory content to the hard disk

Dd If =/dev/MEM of =/root/MEM. Bin BS = 1024 (specify the block size as 1 K)

4. Copy the content of the CD to the specified folder and save it as a CD. ISO file.

Dd If =/dev/CDROM (HDC) of =/root/CD. ISO

Iii. Others

/Dev/null. The nickname is a bottomless pit. You can output any data to it. It can be used without support!

/Dev/zero,It is an input device. You can use it to initialize files.

Reference

Http://blog.csdn.net/liumang_D/article/details/3899462

Http://yjplxq.blog.51cto.com/4081353/947090

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.