Linux basic commands -dd

dd command

dd command to copy the contents of the file and the original file and the format conversion process. dd command function is very powerful, for some of the more underlying problem, use the dd command can often get unexpected results. Or more with the back up dd nude equipment. But not recommended, if you need to backup oracle raw device, you can use rman backup, or use third-party backup software, use dd, it is not easy to manage.

It recommended when there is a need to use dd to the physical disk operation, if it is, then the file system or the use of tar  Backup  cpio other commands more convenient. Further, when using the disk dd operation, preferably the block device file.

grammar

dd (option)
Options
bs = <number of bytes> of: IBS (input) and the old lady (output) to set the number of bytes specified; 
CBS = <number of bytes> : conversion, a time conversion specified number of bytes; 
CONV = <key> : file conversion specified manner; 
COUNT = <block number> : only a specified number of read blocks; 
IBS = <number of bytes> : the number of bytes read at a time; 
OBS = <word section number> : the number of bytes per output; 
of = <file> : output to a file; 
Seek = <block number> : output the outset, to skip a specified number of blocks; 
skip = <block number> : when you start reading, skipping the specified number of blocks;
 - help: help;
 --version: show the version information.

Examples

[root@localhost text]# dd if=/dev/zero of=sun.txt bs=1M count=1
1+0 records in
1+0 records out
1048576 bytes (1.0 MB) copied, 0.006107 seconds, 172 MB/s

[root@localhost text]# du -sh sun.txt 
1.1M    sun.txt

This command creates a file sun.txt 1M size, which explain the parameters:

  • if  the representative of the input file. If you do not specify if, by default it will read input from stdin.
  • of  the representative of the output file. If you do not specify of, the default will be the default stdout output.
  • bs  representative of block size in units of bytes.
  • count  represents the number of blocks to be copied.
  • / dev / zero  is a character device, it will continue to return a zero byte (\ 0).

Unit table block size may be used

Unit size Code
Byte (1B) c
Byte (2B) w
Block (512B) b
Kilobytes (1024B) k
Megabyte (1024KB) M
Gigabytes (1024MB) G

As can be seen above command dd command to test the operation speed of the memory:

1048576 bytes (1.0 MB) copied, 0.006107 seconds, 172 MB/s

 

Guess you like

Origin www.cnblogs.com/lj7xun/p/10983625.html