Linux dd命令

dd - convert and copy a file dd创建指定大小的文件,还可以用来备份,更多详细信息,可以参考man dd页面

命令格式:dd if='input_file" of="output_file" bs="block_size" count="number"

参数说明

  • if:if=FILE 读取FILE替换标准输入
  • of:of=FILE 写入到FILE替换标准输出
  • bs:bs=BYTES 一次读取和写入多少字节
  • count:count=BLOCKS 复制多少输入块

创建指定大小的文件

[root@rhel6164 ~]# dd if=/dev/zero of=/tmp/bigfile bs=1M count=1000
#/dev/zero作为输入文件,会一直输出0,这里创建了一个1000M的文件
1000+0 records in
1000+0 records out
1048576000 bytes (1.0 GB) copied, 11.1137 s, 94.4 MB/s
[root@rhel6164 ~]# du -sch /tmp/bigfile
1001M   /tmp/bigfile
1001M   total
备份数据

[root@rhel6164 ~]# ll /etc/passwd
-rw-r--r-- 1 root root 2373 Jun 10  2014 /etc/passwd
[root@rhel6164 ~]# dd if=/etc/passwd of=/tmp/passwd.bakup 
4+1 records in 
4+1 records out
2373 bytes (2.4 kB) copied, 5.5885e-05 s, 42.5 MB/s
#因为我这里没有指定bs的大小,默认是512Byte,因为上面是2373Byte,所以是上面有4个完整的bs,有一个不是完整的bs
[root@rhel6164 ~]# dd if=/etc/passwd of=/tmp/passwd.bakup1 bs=100
23+1 records in
23+1 records out
2373 bytes (2.4 kB) copied, 5.0871e-05 s, 46.6 MB/s
#这里指定了bs为100Byte,然后就是23个完整的bs

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值