服務(wù)器
本文主要給大家介紹了關(guān)于Linux中dd命令使用的相關(guān)內(nèi)容,分享出來(lái)供大家參考學(xué)習(xí),下面來(lái)看看詳細(xì)的介紹:
創(chuàng)新互聯(lián)專(zhuān)注于雙牌網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠(chéng)為您提供雙牌營(yíng)銷(xiāo)型網(wǎng)站建設(shè),雙牌網(wǎng)站制作、雙牌網(wǎng)頁(yè)設(shè)計(jì)、雙牌網(wǎng)站官網(wǎng)定制、微信小程序開(kāi)發(fā)服務(wù),打造雙牌網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供雙牌網(wǎng)站排名全網(wǎng)營(yíng)銷(xiāo)落地服務(wù)。一、Linux dd命令用指定大小的塊拷貝一個(gè)文件,并在拷貝的同時(shí)進(jìn)行指定的轉(zhuǎn)換。
使用方法:dd [OPERAND]
參數(shù)注釋?zhuān)?/p>
bs=BYTES read and write BYTES bytes at a time (also see ibs=,obs=) cbs=BYTES convert BYTES bytes at a time conv=CONVS convert the file as per the comma separated symbol list count=N copy only N input blocks ibs=BYTES read BYTES bytes at a time (default: 512) if=FILE read from FILE instead of stdin(默認(rèn)為標(biāo)準(zhǔn)輸入) iflag=FLAGS read as per the comma separated symbol list obs=BYTES write BYTES bytes at a time (default: 512) of=FILE write to FILE instead of stdout(默認(rèn)為標(biāo)準(zhǔn)輸出) oflag=FLAGS write as per the comma separated symbol list seek=BLOCKS skip BLOCKS obs-sized blocks at start of output skip=BLOCKS skip BLOCKS ibs-sized blocks at start of input status=WHICH WHICH info to suppress outputting to stderr; \'noxfer\' suppresses transfer stats, \'none\' suppresses all
CONVS的可選參數(shù)
ascii from EBCDIC to ASCII ebcdic from ASCII to EBCDIC ibm from ASCII to alternate EBCDIC block pad newline-terminated records with spaces to cbs-size unblock replace trailing spaces in cbs-size records with newline lcase change upper case to lower case nocreat do not create the output file excl fail if the output file already exists notrunc do not truncate the output file ucase change lower case to upper case sparse try to seek rather than write the output for NUL input blocks swab swap every pair of input bytes noerror continue after read errors sync pad every input block with NULs to ibs-size; when used with block or unblock, pad with spaces rather than NULs fdatasync physically write output file data before finishing fsync likewise, but also write metadata
FLAGS的可選參數(shù)
append append mode (makes sense only for output; conv=notrunc suggested) direct use direct I/O for data directory fail unless a directory dsync use synchronized I/O for data sync likewise, but also for metadata fullblock accumulate full blocks of input (iflag only) nonblock use non-blocking I/O noatime do not update access time noctty do not assign controlling terminal from file nofollow do not follow symlinks count_bytes treat \'count=N\' as a byte count (iflag only)
注意:指定數(shù)字的地方若以下列字符結(jié)尾,則乘以相應(yīng)的數(shù)字:
c =1, w =2, b =512, kB =1000, K =1024, MB =1000*1000, M =1024*1024, xM =M GB =1000*1000*1000, G =1024*1024*1024, and so on for T, P, E, Z, Y
二、使用實(shí)例
1、將本地的/dev/hdb整盤(pán)備份到/dev/hdd
dd if=/dev/hdb of=/dev/hdd
2、將/dev/hdb全盤(pán)數(shù)據(jù)備份到指定路徑的image文件
dd if=/dev/hdb of=/root/image
3、備份/dev/hdb全盤(pán)數(shù)據(jù),并利用gzip工具進(jìn)行壓縮,保存到指定路徑
dd if=/dev/hdb | gzip > /root/image.gz
4、把一個(gè)文件拆分為3個(gè)文件
#文件大小為2.3k [Oracle@rhel6 ~]$ ll db1_db_links.sql -rw-r--r-- 1 oracle oinstall 2344 Nov 21 10:39 db1_db_links.sql #把這個(gè)文件拆成每個(gè)文件1k,bs=1k,count=1,使用skip參數(shù)指定在輸入文件中跳過(guò)多少個(gè)bs支讀取 [oracle@rhel6 ~]$ dd if=db1_db_links.sql of=dd01.sql bs=1k count=1 1+0 records in 1+0 records out 1024 bytes (1.0 kB) copied, 4.5536e-05 s, 22.5 MB/s [oracle@rhel6 ~]$ dd if=db1_db_links.sql of=dd02.sql bs=1k count=1 skip=1 1+0 records in 1+0 records out 1024 bytes (1.0 kB) copied, 0.000146387 s, 7.0 MB/s [oracle@rhel6 ~]$ dd if=db1_db_links.sql of=dd03.sql bs=1k count=1 skip=2 0+1 records in 0+1 records out 296 bytes (296 B) copied, 0.000204216 s, 1.4 MB/s #拆分出的文件 [oracle@rhel6 ~]$ ll dd*sql -rw-r--r-- 1 oracle oinstall 1024 May 20 14:58 dd01.sql -rw-r--r-- 1 oracle oinstall 1024 May 20 14:58 dd02.sql -rw-r--r-- 1 oracle oinstall 296 May 20 14:58 dd03.sql
5、把拆分出的文件合并為1個(gè)
#合并操作,此時(shí)用到seek參數(shù),用于指定在輸入文件中跳過(guò)的bs數(shù) [oracle@rhel6 ~]$ dd of=1.sql if=dd01.sql 2+0 records in 2+0 records out 1024 bytes (1.0 kB) copied, 0.000176 s, 5.8 MB/s [oracle@rhel6 ~]$ dd of=1.sql if=dd02.sql bs=1k seek=1 1+0 records in 1+0 records out 1024 bytes (1.0 kB) copied, 0.000124038 s, 8.3 MB/s [oracle@rhel6 ~]$ dd of=1.sql if=dd03.sql bs=1k seek=2 0+1 records in 0+1 records out 296 bytes (296 B) copied, 0.00203881 s, 145 kB/s #與拆分前的文件進(jìn)行校驗(yàn) [oracle@rhel6 ~]$ diff 1.sql db1_db_links.sql [oracle@rhel6 ~]$
6、在輸出文件中指定的位置插入數(shù)據(jù),而不截?cái)噍敵鑫募?/p>
需要使用conv=notrunc
參數(shù)
[oracle@rhel6 ~]$ dd if=2.sql of=1.sql bs=1k seek=1 count=2 conv=notrunc
總結(jié)
以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來(lái)一定的幫助,如果有疑問(wèn)大家可以留言交流,謝謝大家對(duì)創(chuàng)新互聯(lián)的支持。
本文名稱(chēng):Linux中dd命令使用實(shí)例教程
瀏覽地址:http://www.rwnh.cn/article0/cjppio.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制網(wǎng)站、靜態(tài)網(wǎng)站、用戶(hù)體驗(yàn)、Google、營(yíng)銷(xiāo)型網(wǎng)站建設(shè)、標(biāo)簽優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)