LinuxѹËõ´ò°üÃüÁîʹÓ÷½·¨_Linux·þÎñÆ÷ά»¤_ºÚ¿Í·ÀÏßÍø°²·þÎñÆ÷ά»¤»ùµØ--Powered by WWW.RONGSEN.COM.CN

LinuxѹËõ´ò°üÃüÁîʹÓ÷½·¨

×÷ÕߣººÚ¿Í·ÀÏßÍø°²Î¬»¤ À´Ô´£ººÚ¿Í·ÀÏßÍø°²Íøվά»¤»ùµØ ä¯ÀÀ´ÎÊý£º0

±¾Æª¹Ø¼ü´Ê£ºLinuxѹËõ´ò°ü
ºÚ¿Í·ÀÏßÍø°²ÍøѶ£ºtarÃüÁî[root@linux ~]# tar [-cxtzjvfpPN] ÎļþÓëĿ¼ ²ÎÊý£º-c £º½¨Á¢Ò»¸öѹËõÎļþµÄ²ÎÊýÖ¸Áî(create µÄÒâ˼)£»....
tarÃüÁî[root@linux ~]# tar [-cxtzjvfpPN] ÎļþÓëĿ¼ ....
²ÎÊý£º
-c £º½¨Á¢Ò»¸öѹËõÎļþµÄ²ÎÊýÖ¸Áî(create µÄÒâ˼)£»
-x £º½â¿ªÒ»¸öѹËõÎļþµÄ²ÎÊýÖ¸Á
-t £º²é¿´ tarfile ÀïÃæµÄÎļþ£¡
Ìرð×¢Ò⣬ÔÚ²ÎÊýµÄÏ´ïÖУ¬ c/x/t ½öÄÜ´æÔÚÒ»¸ö£¡²»¿Éͬʱ´æÔÚ£¡
ÒòΪ²»¿ÉÄÜͬʱѹËõÓë½âѹËõ¡£
-z £ºÊÇ·ñͬʱ¾ßÓÐ gzip µÄÊôÐÔ£¿Ò༴ÊÇ·ñÐèÒªÓà gzip ѹËõ£¿
-j £ºÊÇ·ñͬʱ¾ßÓÐ bzip2 µÄÊôÐÔ£¿Ò༴ÊÇ·ñÐèÒªÓà bzip2 ѹËõ£¿
-v £ºÑ¹ËõµÄ¹ý³ÌÖÐÏÔʾÎļþ£¡Õâ¸ö³£Ó㬵«²»½¨ÒéÓÃÔÚ±³¾°Ö´Ðйý³Ì£¡
-f £ºÊ¹ÓõµÃû£¬ÇëÁôÒ⣬ÔÚ f Ö®ºóÒªÁ¢¼´½ÓµµÃûร¡²»ÒªÔÙ¼Ó²ÎÊý£¡
ÀýÈçʹÓẠtar -zcvfP tfile sfile¡»¾ÍÊÇ´íÎóµÄд·¨£¬ÒªÐ´³É
¡º tar -zcvPf tfile sfile¡»²Å¶Ôร¡
-p £ºÊ¹ÓÃÔ­ÎļþµÄÔ­À´ÊôÐÔ£¨ÊôÐÔ²»»áÒÀ¾ÝʹÓÃÕ߶ø±ä£©
-P £º¿ÉÒÔʹÓþø¶Ô·¾¶À´Ñ¹Ëõ£¡
-N £º±ÈºóÃæ½ÓµÄÈÕÆÚ(yyyy/mm/dd)»¹ÒªÐµIJŻᱻ´ò°ü½øн¨µÄÎļþÖУ¡
--exclude FILE£ºÔÚѹËõµÄ¹ý³ÌÖУ¬²»Òª½« FILE ´ò°ü£¡
·¶Àý£º
·¶ÀýÒ»£º½«Õû¸ö /etc Ŀ¼ÏµÄÎļþÈ«²¿´ò°ü³ÉΪ /tmp/etc.tar
[root@linux ~]# tar -cvf /tmp/etc.tar /etc

gzip, zcat ÃüÁî
[root@linux ~]# gzip [-cdt#] µµÃû
[root@linux ~]# zcat µµÃû.gz
²ÎÊý£º
-c £º½«Ñ¹ËõµÄ×ÊÁÏÊä³öµ½Ó©Ä»ÉÏ£¬¿É͸¹ý×ÊÁÏÁ÷Öص¼ÏòÀ´´¦Àí£»
-d £º½âѹËõµÄ²ÎÊý£»
-t £º¿ÉÒÔÓÃÀ´¼ìÑéÒ»¸öѹËõµµµÄÒ»ÖÂÐÔ¡«¿´¿´ÎļþÓÐÎÞ´íÎó£»
-# £ºÑ¹ËõµÈ¼¶£¬-1 ×î¿ì£¬µ«ÊÇѹËõ±È×î²î¡¢-9 ×îÂý£¬µ«ÊÇѹËõ±È×îºÃ£¡Ô¤ÉèÊÇ -6 ¡«
·¶Àý£º
·¶ÀýÒ»£º½« /etc/man.config Ñ}ÖƵ½ /tmp £¬²¢ÇÒÒÔ gzip ѹËõ
[root@linux ~]# cd /tmp
[root@linux tmp]# cp /etc/man.config .
[root@linux tmp]# gzip man.config
# ´Ëʱ man.config »á±ä³É man.config.gz £¡
·¶Àý¶þ£º½«·¶ÀýÒ»µÄÎļþÄÚÈݶÁ³öÀ´£¡
[root@linux tmp]# zcat man.config.gz
# ´ËʱөĻÉÏ»áÏÔʾ man.config.gz ½âѹËõÖ®ºóµÄÎļþÄÚÈÝ£¡£¡
·¶ÀýÈý£º½«·¶ÀýÒ»µÄÎļþ½âѹËõ
[root@linux tmp]# gzip -d man.config.gz
·¶ÀýËÄ£º½«·¶ÀýÈý½â¿ªµÄ man.config ÓÃ×î¼ÑµÄѹËõ±ÈѹËõ£¬²¢±£ÁôÔ­±¾µÄÎļþ
[root@linux tmp]# gzip -9 -c man.config > man.config.gz


bzip2, bzcat ÃüÁî
[root@linux ~]# bzip2 [-cdz] µµÃû
[root@linux ~]# bzcat µµÃû.bz2
²ÎÊý£º
-c £º½«Ñ¹ËõµÄ¹ý³Ì²úÉúµÄ×ÊÁÏÊä³öµ½Ó©Ä»ÉÏ£¡
-d £º½âѹËõµÄ²ÎÊý
-z £ºÑ¹ËõµÄ²ÎÊý
-# £ºÓë gzip ͬÑùµÄ£¬¶¼ÊÇÔÚ¼ÆËãѹËõ±ÈµÄ²ÎÊý£¬ -9 ×î¼Ñ£¬ -1 ×î¿ì£¡
·¶Àý£º
·¶ÀýÒ»£º½«¸Õ¸ÕµÄ /tmp/man.config ÒÔ bzip2 ѹËõ
[root@linux tmp]# bzip2 -z man.config
# ´Ëʱ man.config »á±ä³É man.config.bz2 £¡
·¶Àý¶þ£º½«·¶ÀýÒ»µÄÎļþÄÚÈݶÁ³öÀ´£¡
[root@linux tmp]# bzcat man.config.bz2
# ´ËʱөĻÉÏ»áÏÔʾ man.config.bz2 ½âѹËõÖ®ºóµÄÎļþÄÚÈÝ£¡£¡
·¶ÀýÈý£º½«·¶ÀýÒ»µÄÎļþ½âѹËõ
[root@linux tmp]# bzip2 -d man.config.bz2
·¶ÀýËÄ£º½«·¶ÀýÈý½â¿ªµÄ man.config ÓÃ×î¼ÑµÄѹËõ±ÈѹËõ£¬²¢±£ÁôÔ­±¾µÄÎļþ
[root@linux tmp]# bzip2 -9 -c man.config > man.config.bz2


compress ÃüÁî
[root@linux ~]# compress [-dcr] Îļþ»òĿ¼
²ÎÊý£º
-d £ºÓÃÀ´½âѹËõµÄ²ÎÊý
-r £º¿ÉÒÔÁ¬Í¬Ä¿Â¼ÏµÄÎļþҲͬʱ¸øÓèѹËõÄØ£¡
-c £º½«Ñ¹Ëõ×ÊÁÏÊä³ö³ÉΪ standard output (Êä³öµ½Ó©Ä»)
·¶Àý£º
·¶ÀýÒ»£º½« /etc/man.config Ñ}ÖƵ½ /tmp £¬²¢¼ÓÒÔѹËõ
[root@linux ~]# cd /tmp
[root@linux tmp]# cp /etc/man.config .
[root@linux tmp]# compress man.config
[root@linux tmp]# ls -l
-rw-r--r-- 1 root root 2605 Jul 27 11:43 man.config.Z
·¶Àý¶þ£º½«¸Õ¸ÕµÄѹËõµµ½â¿ª
[root@linux tmp]# compress -d man.config.Z
·¶ÀýÈý£º½« man.config ѹËõ³ÉÁíÍâÒ»¸öÎļþÀ´±¸·Ý
[root@linux tmp]# compress -c man.config > man.config.back.Z
[root@linux tmp]# ll man.config*
-rw-r--r-- 1 root root 4506 Jul 27 11:43 man.config
-rw-r--r-- 1 root root 2605 Jul 27 11:46 man.config.back.Z
# Õâ¸ö -c µÄ²ÎÊý±È½ÏÓÐȤ£¡Ëû»á½«Ñ¹Ëõ¹ý³ÌµÄ×ÊÁÏÊä³öµ½Ó©Ä»ÉÏ£¬¶ø²»ÊÇдÈë³ÉΪ
# file.Z Îļþ¡£ËùÒÔ£¬ÎÒÃÇ¿ÉÒÔ͸¹ý×ÊÁÏÁ÷Öص¼ÏòµÄ·½·¨½«×ÊÁÏÊä³ö³ÉΪÁíÒ»¸öµµÃû¡£
# ¹Øì¶×ÊÁÏÁ÷Öص¼Ïò£¬ÎÒÃÇ»áÔÚ bash shell µ±ÖÐÏêϸ̸ÂÛµÄÀ²£¡

dd ÃüÁî
[root@linux ~]# dd if="input_file" of="outptu_file" bs="block_size"
count="number"
²ÎÊý£º
if £º¾ÍÊÇ input file †ª¡«Ò²¿ÉÒÔÊÇ×°ÖÃร¡
of £º¾ÍÊÇ output file ม«Ò²¿ÉÒÔÊÇ×°Öã»
bs £º¹æ»®µÄÒ»¸ö block µÄ´óС£¬Èç¹ûûÓÐÉ趨ʱ£¬Ô¤ÉèÊÇ 512 bytes
count£º¶àÉÙ¸ö bs µÄÒâ˼¡£
·¶Àý£º
·¶ÀýÒ»£º½« /etc/passwd ±¸·Ýµ½ /tmp/passwd.back µ±ÖÐ
[root@linux ~]# dd if=/etc/passwd of=/tmp/passwd.back
3+1 records in
3+1 records out
[root@linux ~]# ll /etc/passwd /tmp/passwd.back
-rw-r--r-- 1 root root 1746 Aug 25 14:16 /etc/passwd
-rw-r--r-- 1 root root 1746 Aug 29 16:57 /tmp/passwd.back
# ×ÐϸµÄ¿´Ò»Ï£¬ÎÒµÄ /etc/passwd Îļþ´óСΪ 1746 bytes£¬ÒòΪÎÒûÓÐÉ趨 bs £¬
# ËùÒÔÔ¤ÉèÊÇ 512 bytes Ϊһ¸öµ¥Î»£¬Òò´Ë£¬ÉÏÃæÄǸö 3+1 ±íʾÓÐ 3 ¸öÍêÕûµÄ
# 512 bytes£¬ÒÔ¼°Î´Âú 512 bytes µÄÁíÒ»¸ö block µÄÒâ˼À²£¡
# ÊÂʵÉÏ£¬¸Ð¾õºÃÏñÊÇ cp Õâ¸öÖ¸ÁîÀ²¡«
·¶Àý¶þ£º±¸·Ý /dev/hda µÄ MBR
[root@linux ~]# dd if=/dev/hda of=/tmp/mbr.back bs=512 count=1
1+0 records in
1+0 records out
# Õâ¾ÍµÃºÃºÃ²t½âһφª¡«ÎÒÃÇÖªµÀÕû¿ÅÓ²ÅÌµÄ MBR Ϊ 512 bytes£¬
# ¾ÍÊÇ·ÅÔÚÓ²Å̵ĵÚÒ»¸ö sector À²£¬Òò´Ë£¬ÎÒ¿ÉÒÔÀûÓÃÕâ¸ö·½Ê½À´½«
# MBR ÄÚµÄËùÓÐ×ÊÁ϶¼¼Í¼ÏÂÀ´£¬ÕæµÄºÜÀ÷º¦°É£¡ ^_^
·¶ÀýÈý£º½«Õû¸ö /dev/hda1 partition ±¸·ÝÏÂÀ´¡£
[root@linux ~]# dd if=/dev/hda1 of=/some/path/filenaem
# Õâ¸öÖ¸ÁîºÜÀ÷º¦°¡£¡½«Õû¸ö partition µÄÄÚÈÝÈ«²¿±¸·ÝÏÂÀ´¡«
# ºóÃæ½ÓµÄ of ±ØÐëÒª²»ÊÇÔÚ /dev/hda1 µÄĿ¼ÄÚ°¡¡«·ñÔò£¬Ôõô¶ÁÒ²¶Á²»Íê¡«
# Õâ¸ö¶¯×÷ÊǺÜÓÐЧÓõģ¬Èç¹û¸ÄÌìÄã±ØÐëÒªÍêÕûµÄ½«Õû¸ö partition µÄÄÚÈÝÌî»ØÈ¥£¬
# Ôò¿ÉÒÔÀûÓà dd if=/some/file of=/dev/hda1 À´½«×ÊÁÏдÈëµ½Ó²Å̵±ÖС£
# Èç¹ûÏëÒªÕû¸öÓ²Å̱¸·ÝµÄ»°£¬¾ÍÀàËÆ Norton µÄ ghost ÈíÌåÒ»°ã£¬
# ÓÉ disk µ½ disk £¬ºÙºÙ¡«ÀûÓà dd ¾Í¿ÉÒÔÀ²¡«À÷º¦À÷º¦£¡

cpio ÃüÁî
[root@linux ~]# cpio -covB > [file|device]
[root@linux ~]# cpio -icduv 
²ÎÊý£º
-o £º½«×ÊÁÏ copy Êä³öµ½Îļþ»ò×°ÖÃÉÏ
-i £º½«×ÊÁÏ×ÔÎļþ»ò×°Öà copy ³öÀ´ÏµÍ³µ±ÖÐ
-t £º²é¿´ cpio ½¨Á¢µÄÎļþ»ò×°ÖõÄÄÚÈÝ
-c £ºÒ»ÖÖ½ÏÐ嵀 portable format ·½Ê½´¢´æ
-v £ºÈô¢´æµÄ¹ý³ÌÖÐÎļþÃû³Æ¿ÉÒÔÔÚÓ©Ä»ÉÏÏÔʾ
-B £ºÈÃÔ¤ÉèµÄ Blocks ¿ÉÒÔÔö¼ÓÖÁ 5120 bytes £¬Ô¤ÉèÊÇ 512 bytes £¡
ÕâÑùµÄºÃ´¦ÊÇ¿ÉÒÔÈôóÎļþµÄ´¢´æËٶȼӿì(Çë²Î¿¼ i-nodes µÄ¹ÛÄî)
-d £º×Ô¶¯½¨Á¢Ä¿Â¼£¡ÓÉì¶ cpio µÄÄÚÈÝ¿ÉÄܲ»ÊÇÔÚͬһ¸öĿ¼ÄÚ£¬
Èç´ËµÄ»°ÔÚ·´±¸·ÝµÄ¹ý³Ì»áÓÐÎÊÌ⣡ Õâ¸öʱºò¼ÓÉÏ -d µÄ»°£¬
¾Í¿ÉÒÔ×Ô¶¯µÄ½«ÐèÒªµÄĿ¼½¨Á¢ÆðÀ´ÁË£¡
-u £º×Ô¶¯µÄ½«½ÏеÄÎļþ¸²¸Ç½Ï¾ÉµÄÎļþ£¡
·¶Àý£º
·¶ÀýÒ»£º½«ËùÓÐϵͳÉϵÄ×ÊÁÏͨͨдÈë´Å´ø»úÄÚ£¡
[root@linux ~]# find / -print | cpio -covB > /dev/st0
# Ò»°ãÀ´Ëµ£¬Ê¹Óà SCSI ½éÃæµÄ´Å´ø»ú£¬´úºÅÊÇ /dev/st0 ร¡
·¶Àý¶þ£º¼ì²é´Å´ø»úÉÏÃæÓÐʲôÎļþ£¿
[root@linux ~]# cpio -icdvt
[root@linux ~]# cpio -icdvt  /tmp/content
# µÚÒ»¸ö¶¯×÷µ±ÖУ¬»á½«´Å´ø»úÄڵĵµÃûÁгöµ½Ó©Ä»ÉÏÃ棬¶øÎÒÃÇ¿ÉÒÔ͸¹ýµÚ¶þ¸ö¶¯×÷£¬
# ½«ËùÓеĵµÃûͨͨ¼Í¼µ½ /tmp/content ÎļþÈ¥£¡
·¶ÀýÈý£º½«´Å´øÉϵÄ×ÊÁÏ»¹Ô­»ØÀ´¡«
[root@linux ~]# cpio -icduv
# Ò»°ãÀ´Ëµ£¬Ê¹Óà SCSI ½éÃæµÄ´Å´ø»ú£¬´úºÅÊÇ /dev/st0 ร¡
·¶ÀýËÄ£º½« /etc µ×ϵÄËùÓСºÎļþ¡»¶¼±¸·Ýµ½ /root/etc.cpio ÖУ¡
[root@linux ~]# find /etc -type f | cpio -o > /root/etc.cpio
# ÕâÑù¾ÍÄܹ»±¸·Ý†ª¡«ÄúÒ²¿ÉÒÔ½«×ÊÁÏÒÔ cpio -i
    ºÚ¿Í·ÀÏßÍø°²·þÎñÆ÷ά»¤·½°¸±¾ÆªÁ¬½Ó£ºhttp://www.rongsen.com.cn/show-6911-1.html
Íøվά»¤½Ì³Ì¸üÐÂʱ¼ä:2011-08-06 02:25:24  ¡¾´òÓ¡´ËÒ³¡¿  ¡¾¹Ø±Õ¡¿
ÎÒÒªÉêÇë±¾Õ¾£ºNµã | ºÚ¿Í·ÀÏß¹ÙÍø |  
רҵ·þÎñÆ÷ά»¤¼°Íøվά»¤ÊÖ¹¤°²È«´î½¨»·¾³£¬ÍøÕ¾°²È«¼Ó¹Ì·þÎñ¡£ºÚ¿Í·ÀÏßÍø°²·þÎñÆ÷ά»¤»ùµØÕÐÉ̽øÐÐÖУ¡QQ:29769479

footer  footer  footer  footer