Linux Special command--DD and Linux patch making

Source: Internet
Author: User
Tags diff

One, DD command detailed:

Official explanation: Convert and copy a file---transform and copy files

DD is a very useful command under Linux/unix, which is to copy a file with a block of the specified size and make the specified conversion at the same time as the copy

Grammar:

DD [OPERAND] ...

DD OPTION

Parameters:

If=file read from FILE instead of stdin

source file for specifying the source of the data stream

Of=file write to FILE instead of stdout

Target file for specifying the data flow storage destination

Bs=bytes Read and write BYTES BYTES at a time (also see ibs=,obs=)

Amount of data for one IO

Count=n Copy only N input blocks

How many BS specified blocks are copied

Format:

DD if= of= bs= count=


Two special device files

/dev/null:bit Bucket is known as a data black hole, you can enter any information to him without any output

/dev/zero: is an input device that you can use to initialize a file, which provides an infinite 0 string that can be used to write a string 0 to a file or device;

Eg: Create a file with a size of 64M

[[email protected] tmp]# mkdir zero[[email protected] tmp]# CD Zero[[email protected] zero]# ls-ltotal 0[[email protected ] zero]# dd If=/dev/zero of=/tmp/zero/file bs=1m count=6464+0 Records in64+0 records out67108864 bytes (MB) copied, 0.4 34439 S, 154 mb/s[[email protected] zero]# ls-lhtotal 64m-rw-r--r--1 root root 64M Apr 1 16:42 file

Application Examples:

App 1: Create a local loopback device file:

DD If=/dev/zero of=/path/to/somefile bs= count=

App 2: backup disk starts with 512 byte-sized MBR information to the specified file:

DD IF=/DEV/SDA of=/backup/mbr.backup bs=512 count=1

Restore MBR

DD If=/backup/mbr.backup OF=/DEV/SDA


Application 3: Destroying its MBR (instantly destroying its partitioned table, extremely destructive)

DD If=/dev/zero OF=/DEV/SDA bs=512 count=1

Apply 4, Destroy disk data

[email protected] zero]# DD if=/dev/urandom of=/dev/sdb


Second, text comparison, patch making and patching tools----diff,patch

Diff command

the diff command is a very important tool on Linux to compare the contents of a file, especially to compare two different versions of a file to find the place to change

Command format:

diff[parameter [file 1 or directory 1][file 2 or directory 2]


Linux Patch Production

diff [-u] file.old file.new >file.patch

Patch File.old <file.patch

Eg:[[email protected] ~]# diff functions Functions.1 4a5> #Author: [email protected][[email protected] ~]# diff-u func tions functions.1 > Functions.patch//Make patches [[email protected] ~]# patch functions <functions.patch//patch [email prot Ected] ~]# head-5 functions#-*-shell-script-*-## functionsthis file contains functions to BES used by most or All#shell s Cripts in The/etc/init.d directory. #Author: [Email protected]




This article is from the "impermanence" blog, please be sure to keep this source http://1inux.blog.51cto.com/10037358/1629382

Linux Special command--DD and Linux patch making

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.