English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Linux dd command

Linux Command大全

The Linux dd command is used to read, convert, and output data.

dd can read data from standard input or file, convert data according to the specified format, and then output to file, device, or standard output.

Parameter description:

  • if=file name: Input file name, default is standard input. That is, specify the source file.
  • of=file name: Output file name, default is standard output. That is, specify the destination file.
  • ibs=bytes: Read in bytes bytes at a time, that is, specify a block size of bytes bytes.
    obs=bytes: Output bytes bytes at a time, that is, specify a block size of bytes bytes.
    bs=bytes: Set read-in and output at the same time/The output block size is bytes bytes.
  • cbs=bytes: Convert bytes bytes at a time, that is, specify the conversion buffer size.
  • skip=blocks: Skip blocks blocks from the beginning of the input file before starting to copy.
  • seek=blocks: Skip blocks blocks from the beginning of the output file before starting to copy.
  • count=blocks: Copy only blocks blocks, where block size is the number of bytes specified by ibs.
  • conv=<keyword>, the keyword can be one of the following11Type:
    • conversion: Convert the file with specified parameters.
    • ascii: Convert ebcdic to ascii
    • ebcdic: Convert ascii to ebcdic
    • ibm: Convert ascii to alternate ebcdic
    • block: Convert each line to length cbs, and fill the insufficient part with spaces
    • unblock: Make each line length cbs, and fill the insufficient part with spaces
    • lcase: Convert uppercase characters to lowercase
    • ucase: Convert lowercase characters to uppercase
    • swap: Swap each pair of input bytes
    • noerror: Do not stop when an error occurs
    • notrunc: Do not truncate the output file
    • sync: Fill each input block to ibs bytes, and use null characters to fill the insufficient part.
  • --help: Display help information
  • --version: Display version information

Online example

To create a bootable disk in Linux, you can use the following command:

dd if=boot.img of=/dev/fd0 bs=1440k 

Convert all the English letters in the testfile file to uppercase and then convert to testfile_1Use the following command in the command prompt:

dd if=testfile_2 of=testfile_1 conv=ucase 

where testfile_2 The content is:

$ cat testfile_2 #testfile_2content  
HELLO LINUX!  
Linux is a free unix-type operating system.  
This is a linux testfile!  
Linux test 

After the conversion is complete, testfile_1 The content is as follows:

$ dd if=testfile_2 of=testfile_1 conv=ucase #Using the dd command, case conversion recorded 0+1 of the input  
Recorded 0+1 of the output  
95bytes (95 B) Copied, 0.000131446 seconds,723 KB/s  
cmd@hdd-desktop:~$ cat testfile_1 #View the converted testfile_1File Content  
HELLO LINUX!  
LINUX IS A FREE UNIX-TYPE OPERATING SYSTEM.  
THIS IS A LINUX TESTFILE!  
LINUX TEST #testfile_2All characters have been converted to uppercase letters 

The string read from the standard input device is converted to uppercase and then output to the standard output device, using the command:

dd conv=ucase 

Press Enter after entering the above command, enter a string, and then press Enter again, and press the combination key Ctrl+D Exit, the following result appears:

$ dd conv=ucase 
Hello Linux! #Press the Enter key after entering the string  
HELLO LINUX! #Press the combination key Ctrl+D Exit, convert the result to uppercase  
Recorded 0+1 of the input  
Recorded 0+1 of the output  
13bytes (13 B) Copied,12.1558 seconds, 0.0 KB/s 

Linux Command大全