Linuxの下のddとcat

2987 ワード

linuxの下の2つの実用的なコマンド、1つの切り分け、1つのマージ.非常に実用的である.
1. dd
ddのパラメータ:
Copy a file, converting and formatting according to the operands.

  bs=BYTES        read and write up to BYTES bytes at a time
  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 up to 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=N          skip N obs-sized blocks at start of output
  skip=N          skip N ibs-sized blocks at start of input
  status=WHICH    WHICH info to suppress outputting to stderr;
                  'noxfer' suppresses transfer stats, 'none' suppresses all

ifとofは入出力
countは操作するブロック数です
bsはブロックの大きさです
seekはn個の出力を省略したブロック再書き込みである
skipは入力を省略したブロック数です
2.catコマンド
簡単な一般的な方法の一つは、2つのファイルを統合することです.
cat a b >c
3.その他の応用
1.    /dev/hdb     /dev/hdd
   dd if=/dev/hdb f=/dev/hdd              hdb –>    -> hdd
2. /dev/hdb            image  
   dd if=/dev/hdb f=/root/image            hdb –>    -> image  
3.           
   dd if=/root/image f=/dev/hdb             image   –>    -> hdb
4.  /dev/hdb    ,   gzip      ,       
    dd if=/dev/hdb | gzip> /root/image.gz
5.              
   gzip -dc /root/image.gz | dd f=/dev/hdb
6.       512      MBR             
   dd if=/dev/hda f=/root/image count=1 bs=512        0  0  1    512   
   count=1       ;bs=512     512   。
     :dd if=/root/image f=/dev/hda
7.    
   dd if=/dev/fd0 f=disk.img count=1  bs=1440k (     1.44M)
8.         
   dd if=/dev/mem f=/root/mem.bin  bs=1024 (      1k)  
9.            ,    cd.iso    
   dd if=/dev/cdrom(hdc)   of=/root/cd.iso
10.  swap        
   :       256M   :
dd if=/dev/zero  of=/swapfile  bs=1024 count=262144
   :       swap      :
mkswap /swapfile
   :    swap      :
swapon /swapfile
   :  /etc/fstab  ,           swap      :
/swapfile    swap    swap    default   0 0
11.      
     dd if=/dev/urandom f=/dev/hda1
  :           ,                。
12.         
     dd if=/dev/zero bs=1024 count=1000000 f=/root/1Gb.file       
      dd if=/root/1Gb.file bs=64k | dd f=/dev/null         
                 ,         、   。
13.        blocks  :     
     dd if=/dev/zero bs=1024 count=1000000 f=/root/1Gb.file         
     dd if=/dev/zero bs=2048 count=500000 f=/root/1Gb.file          
     dd if=/dev/zero bs=4096 count=250000 f=/root/1Gb.file          
     dd if=/dev/zero bs=8192 count=125000 f=/root/1Gb.file          
                     ,            。
14.    :                       
     dd if=/dev/sda f=/dev/sda  SCSI    dd if=/dev/hda f=/dev/hda   IDE