一、dd命令用指定大小的块拷贝一个文件,并在拷贝的同时进行指定的转换。

使用方法:dd [OPERAND]

参数注释: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(默认为标准输入)

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(默认为标准输出)

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的可选参数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的可选参数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)

注意:指定数字的地方若以下列字符结尾,则乘以相应的数字:

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

二、使用实例

1、将本地的/dev/hdb整盘备份到/dev/hdddd if=/dev/hdb of=/dev/hdd

2、将/dev/hdb全盘数据备份到指定路径的p_w_picpath文件dd if=/dev/hdb of=/root/p_w_picpath

3、备份/dev/hdb全盘数据,并利用gzip工具进行压缩,保存到指定路径dd if=/dev/hdb | gzip > /root/p_w_picpath.gz

4、把一个文件拆分为3个文件#文件大小为2.3k

[oracle@rhel6 ~]$ ll db1_db_links.sql

-rw-r--r-- 1 oracle oinstall 2344 Nov 21 10:39 db1_db_links.sql

#把这个文件拆成每个文件1k,bs=1k,count=1,使用skip参数指定在输入文件中跳过多少个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个#合并操作,此时用到seek参数,用于指定在输入文件中跳过的bs数

[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

#与拆分前的文件进行校验

[oracle@rhel6 ~]$ diff 1.sql db1_db_links.sql

[oracle@rhel6 ~]$

6、在输出文件中指定的位置插入数据,而不截断输出文件需要使用conv=notrunc参数

[oracle@rhel6 ~]$ dd if=2.sql of=1.sql bs=1k seek=1 count=2 conv=notrunc

linux 下的dd,Linux中的dd命令相关推荐

  1. linux用户密码转换为明文,Linux运维知识之linux下抓取内存中明文密码mimipenguin

    本文主要向大家介绍了Linux运维知识之linux下抓取内存中明文密码mimipenguin,通过具体的内容向大家展现,希望对大家学习Linux运维知识有所帮助. 下载地址:https://githu ...

  2. linux列举网卡,linux下快速列出局域网中所有主机名(计算机名)的脚本

    linux下快速列出局域网中所有主机名(计算机名)的脚本,脚本,主机名,网中,站长站,命令 linux下快速列出局域网中所有主机名(计算机名)的脚本 易采站长站,站长之家为您整理了linux下快速列出 ...

  3. 脚本同步mysql数据_windows下数据库文件使用脚本同步到linux下的mysql数据库中

    1.背景 windows server 2008 下 每天会有 *.sql数据文件 需要上传到linux 中的mysql数据库中 而运维人员是在 windows server 下使用 xshell 连 ...

  4. linux下上传系统中文件到gitHub

    linux下上传系统中文件到gitHub 一: 1系统下生成公钥 #ssh-keygen 一路回车即可 2对公钥进行复制 #cat .shh/id_rsa.pub 3将公钥复制到github中 首先要 ...

  5. linux中替换文件中的内容,linux下批量替换文件中的内容linux操作系统 -电脑资料...

    对于单个文件,使用sed命令很容易做到, grep命令可以查找单个文件或文件夹下文件中的内容,使用参数"r"或"-R"可以递归查找指定文件夹下的所有文件:参数& ...

  6. linux单步调试方法,linux下gdb单步调试(中).doc

    linux下gdb单步调试(中) linux下gdb单步调试(中) linux下gdb单步调试(中) 一.设置断点( BreakPoint ) 我们用 break 命令来设置断点.正面有几点设置断点的 ...

  7. 在linux下nice用法,Linux下nice/renice命令小结

    1. nice命令 内核根据进程的nice值决定进程需要多少处理器时间. nice值的取值范围是是: -20到20. 一个具有-20 的 nice 值的进程有很高的优先级. 一个 nice 值为 20 ...

  8. Linux下ps查找进程用kill终止命令

    Linux下ps查找进程用kill终止命令<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:offic ...

  9. Linux下必须知道的11个网络命令

    Linux下必须知道的11个网络命令 作者:佚名 字体:[增加 减小] 来源:互联网 时间:03-06 15:54:29 我要评论 无论你是要下载文件.诊断网络问题.管理网络接口,还是查看网络的统计数 ...

  10. Linux下常见文件解压方法及命令

    Linux下常见文件解压方法及命令时间:2007-01-08 18:34来源:CSDN作者:bitsCN编辑字体:[大 中 小]1.以.a为扩展名的文件: #tar xv file.a 2.以.z为扩 ...

最新文章

  1. linuex查看繁忙_如何用九条命令在一分钟内检查Linux服务器性能?
  2. h5移动端如何让页面强制横屏
  3. Zuul指定path+serviceid
  4. 0间隔24h采集线报+源码的资源网
  5. android 布局可大可小,UI设计教程之:ios与android ui适配(将IOS UI转换成Android经验畅谈)...
  6. JAVA简单选择排序算法原理及实现
  7. 在Mybatis的collection标签中获取以,分隔的id字符串
  8. cv2 python 多线程调用摄像头_2种方法用python调用cv2模块给图片打马赛克
  9. oracle 分析函数之分组求和、连续求和
  10. Unity 3D 特效学习记录
  11. 10 种为React应用程序设计样式的方法
  12. 设计模式 “之“ 责任链模式
  13. [2022软工第三次作业]结对编程项目——最长英语单词链
  14. 领导最不赏识这5类下属
  15. 【工大SCIR笔记】多方对话研究简述
  16. 本人亲自整理的极客时间设计模式之美下部的硬核笔记(残缺版)最近加班太多,搞不了太多,只能尽量了xd们
  17. 苹果手机解压缩软件_最近很火的解压缩软件Bandizip
  18. Googlenet v1、v2、v3、v4区别
  19. Navicat导出整个数据库(可以直接迁移,不会因为外键关系而导致导入不了)
  20. Chapter_one

热门文章

  1. mac版python连接mysql_Mac下Python连接MySQL · BlBana’s BlackHouse
  2. php 协程怎么用,PHP yield 协程 生成器用法的了解
  3. python任务调度平台 界面_任务调度平台Cuckoo-Schedule
  4. mapinfo在线地图插件_表格中如何可视化地址数据?用 SeaTable 的地图插件很方便...
  5. oracle对查询结果求和_某国企Oracle数据库误truncate table恢复案例
  6. Jenkins之gitlab配置
  7. java读取大txt文件_使用java读取txt里边的文件内容并获取大小(M).txt
  8. php贺卡生成,用php与mysql的电子贺卡程序
  9. 搜狗拼音输入法5.0_如何用搜狗拼音输入法输入生僻字?
  10. arraylist切割_JAVA List和Map切割工具详解