Linux 特殊命令--dd 及Linux補丁製作

來源:互聯網
上載者:User

標籤:dd命令 /dev/null 、 /dev/zero 檔案比較

一、dd 命令詳解:

        官方解釋: convert and copy a file ---轉換並複製檔案

        dd 是 Linux/UNIX 下的一個非常有用的命令,作用是用指定大小的塊拷貝一個檔案,並在拷貝的同時進行指定的轉換

文法:

       dd [OPERAND]...

       dd OPTION

參數:

       if=FILE       read from FILE instead of stdin

                 源檔案,用於指定資料流來源     

       of=FILE     write to FILE instead of stdout 

                目標檔案,用於指定資料流儲存目標

       bs=BYTES      read and write BYTES bytes at a time (also see ibs=,obs=)

                一次io的資料量

       count=N         copy only N input blocks

                複製多少個bs指定的block

格式:

                dd if= of= bs= count=


兩個特殊裝置檔案

                /dev/null: bit bucket  號稱資料黑洞,你可以向他輸入任何資訊,而不會有任何輸出

                /dev/zero: 是一個輸入裝置,你可用它來初始設定檔案;該裝置可以無窮盡的提供0字串,該裝置可用於向檔案或裝置寫入字串0;

eg:建立一個大小為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 (67 MB) copied, 0.434439 s, 154 MB/s[[email protected] zero]# ls -lhtotal 64M-rw-r--r-- 1 root root 64M Apr  1 16:42 file

應用執行個體:

        應用1:建立本地迴環裝置檔案:

dd if=/dev/zero of=/PATH/TO/SOMEFILE bs= count=

        應用2:備份磁碟開始的512個位元組大小的MBR資訊到指定檔案:

dd if=/dev/sda of=/backup/mbr.backup bs=512 count=1

恢複MBR

dd if=/backup/mbr.backup of=/dev/sda


        應用3:破壞其MBR (瞬間破壞其分區表,極度具有破壞性)

dd if=/dev/zero of=/dev/sda bs=512 count=1

        應用4、銷毀磁碟資料

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


二、文本比較、補丁製作及打補丁工具----diff,patch 

diff 命令

               diff命令 是 linux上非常重要的工具,用於比較檔案的內容,特別是比較兩個版本不同的檔案以找到改動的地方

    命令格式:

            diff[參數][檔案1或目錄1][檔案2或目錄2]


Linux補丁製作

        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 functions functions.1 > functions.patch //製作補丁[[email protected] ~]# patch functions <functions.patch  //打補丁[[email protected] ~]# head -5 functions# -*-Shell-script-*-## functionsThis file contains functions to be used by most or all#shell scripts in the /etc/init.d directory.#Author: [email protected]




本文出自 “無常” 部落格,請務必保留此出處http://1inux.blog.51cto.com/10037358/1629382

Linux 特殊命令--dd 及Linux補丁製作

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.