{"id":507,"date":"2017-05-22T15:21:00","date_gmt":"2017-05-22T07:21:00","guid":{"rendered":"https:\/\/blog.freesilo.com\/?p=507"},"modified":"2017-05-22T15:21:00","modified_gmt":"2017-05-22T07:21:00","slug":"linux%e5%8e%8b%e7%bc%a9%e6%89%93%e5%8c%85%e5%91%bd%e4%bb%a4","status":"publish","type":"post","link":"https:\/\/freesilo.com\/?p=507","title":{"rendered":"Linux\u538b\u7f29\u6253\u5305\u547d\u4ee4"},"content":{"rendered":"<h2>tar\u547d\u4ee4<\/h2>\n<pre> [root@linux ~]# tar [-cxtzjvfpPN] \u6587\u4ef6\u4e0e\u76ee\u5f55 ....\r\n<\/pre>\n<p><a name=\".E5.8F.82.E6.95.B0\"><\/a><\/p>\n<h3><a name=\"t1\"><\/a>\u53c2\u6570<\/h3>\n<dl>\n<dd>-c \uff1a\u5efa\u7acb\u4e00\u4e2a\u538b\u7f29\u6587\u4ef6\u7684\u53c2\u6570\u6307\u4ee4(create \u7684\u610f\u601d)\uff1b<\/dd>\n<dd>-x \uff1a\u89e3\u5f00\u4e00\u4e2a\u538b\u7f29\u6587\u4ef6\u7684\u53c2\u6570\u6307\u4ee4\uff01<\/dd>\n<dd>-t \uff1a\u67e5\u770b tarfile \u91cc\u9762\u7684\u6587\u4ef6\uff01<\/dd>\n<dd>\u7279\u522b\u6ce8\u610f\uff0c\u5728\u53c2\u6570\u7684\u4e0b\u8fbe\u4e2d\uff0c c\/x\/t \u4ec5\u80fd\u5b58\u5728\u4e00\u4e2a\uff01\u4e0d\u53ef\u540c\u65f6\u5b58\u5728\uff01\u56e0\u4e3a\u4e0d\u53ef\u80fd\u540c\u65f6\u538b\u7f29\u4e0e\u89e3\u538b\u7f29\u3002<\/dd>\n<dd>-z \uff1a\u662f\u5426\u540c\u65f6\u5177\u6709 gzip \u7684\u5c5e\u6027\uff1f\u4ea6\u5373\u662f\u5426\u9700\u8981\u7528 gzip \u538b\u7f29\uff1f<\/dd>\n<dd>-j \uff1a\u662f\u5426\u540c\u65f6\u5177\u6709 bzip2 \u7684\u5c5e\u6027\uff1f\u4ea6\u5373\u662f\u5426\u9700\u8981\u7528 bzip2 \u538b\u7f29\uff1f<\/dd>\n<dd>-v \uff1a\u538b\u7f29\u7684\u8fc7\u7a0b\u4e2d\u663e\u793a\u6587\u4ef6\uff01\u8fd9\u4e2a\u5e38\u7528\uff0c\u4f46\u4e0d\u5efa\u8bae\u7528\u5728\u80cc\u666f\u6267\u884c\u8fc7\u7a0b\uff01<\/dd>\n<dd>-f \uff1a\u4f7f\u7528\u6863\u540d\uff0c\u8bf7\u7559\u610f\uff0c\u5728 f \u4e4b\u540e\u8981\u7acb\u5373\u63a5\u6863\u540d\u5594\uff01\u4e0d\u8981\u518d\u52a0\u53c2\u6570\uff01<\/dd>\n<dd>\u4f8b\u5982\u4f7f\u7528\u300e tar -zcvfP tfile sfile\u300f\u5c31\u662f\u9519\u8bef\u7684\u5199\u6cd5\uff0c\u8981\u5199\u6210\u300e tar -zcvPf tfile sfile\u300f\u624d\u5bf9\u5594\uff01<\/dd>\n<dd>-p \uff1a\u4f7f\u7528\u539f\u6587\u4ef6\u7684\u539f\u6765\u5c5e\u6027\uff08\u5c5e\u6027\u4e0d\u4f1a\u4f9d\u636e\u4f7f\u7528\u8005\u800c\u53d8\uff09<\/dd>\n<dd>-P \uff1a\u53ef\u4ee5\u4f7f\u7528\u7edd\u5bf9\u8def\u5f84\u6765\u538b\u7f29\uff01<\/dd>\n<dd>-N \uff1a\u6bd4\u540e\u9762\u63a5\u7684\u65e5\u671f(yyyy\/mm\/dd)\u8fd8\u8981\u65b0\u7684\u624d\u4f1a\u88ab\u6253\u5305\u8fdb\u65b0\u5efa\u7684\u6587\u4ef6\u4e2d\uff01<\/dd>\n<dd>&#8211;exclude FILE\uff1a\u5728\u538b\u7f29\u7684\u8fc7\u7a0b\u4e2d\uff0c\u4e0d\u8981\u5c06 FILE \u6253\u5305\uff01<\/dd>\n<\/dl>\n<p><a name=\".E8.8C.83.E4.BE.8B\"><\/a><\/p>\n<h3><a name=\"t2\"><\/a>\u8303\u4f8b<\/h3>\n<ul>\n<li>\u8303\u4f8b\u4e00\uff1a\u5c06\u6574\u4e2a \/etc \u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\u5168\u90e8\u6253\u5305\u6210\u4e3a \/tmp\/etc.tar<\/li>\n<\/ul>\n<pre>[root@linux ~]# tar -cvf \/tmp\/etc.tar \/etc &lt;==\u4ec5\u6253\u5305\uff0c\u4e0d\u538b\u7f29\uff01<\/pre>\n<pre>[root@linux ~]# tar -zcvf \/tmp\/etc.tar.gz \/etc &lt;==\u6253\u5305\u540e\uff0c\u4ee5 gzip \u538b\u7f29<\/pre>\n<pre>[root@linux ~]# tar -jcvf \/tmp\/etc.tar.bz2 \/etc &lt;==\u6253\u5305\u540e\uff0c\u4ee5 bzip2 \u538b\u7f29\r\n<\/pre>\n<p>\u7279\u522b\u6ce8\u610f\uff0c\u5728\u53c2\u6570 f \u4e4b\u540e\u7684\u6587\u4ef6\u6863\u540d\u662f\u81ea\u5df1\u53d6\u7684\uff0c\u6211\u4eec\u4e60\u60ef\u4e0a\u90fd\u7528 .tar \u6765\u4f5c\u4e3a\u8fa8\u8bc6\u3002\uff0c\u5982\u679c\u52a0 z \u53c2\u6570\uff0c<\/p>\n<p>\u5219\u4ee5 .tar.gz \u6216 .tgz \u6765\u4ee3\u8868 gzip \u538b\u7f29\u8fc7\u7684 tar file \uff5e\uff0c\u5982\u679c\u52a0 j \u53c2\u6570\uff0c<\/p>\n<p>\u5219\u4ee5 .tar.bz2 \u6765\u4f5c\u4e3a\u9644\u6863\u540d\u554a\uff5e\uff0c\u4e0a\u8ff0\u6307\u4ee4\u5728\u6267\u884c\u7684\u65f6\u5019\uff0c<\/p>\n<p>\u4f1a\u663e\u793a\u4e00\u4e2a\u8b66\u544a\u8baf\u606f\uff1a\u300etar: Removing leading `\/&#8217; from member names\u300f\u90a3\u662f\u5173\u65bc\u7edd\u5bf9\u8def\u5f84\u7684\u7279\u6b8a\u8bbe\u5b9a\u3002<\/p>\n<ul>\n<li>\u8303\u4f8b\u4e8c\uff1a\u67e5\u9605\u4e0a\u8ff0 \/tmp\/etc.tar.gz \u6587\u4ef6\u5185\u6709\u54ea\u4e9b\u6587\u4ef6\uff1f<\/li>\n<\/ul>\n<pre>[root@linux ~]# tar -ztvf \/tmp\/etc.tar.gz\r\n<\/pre>\n<p>\u7531\u65bc\u6211\u4eec\u4f7f\u7528 gzip \u538b\u7f29\uff0c\u6240\u4ee5\u8981\u67e5\u9605\u8be5 tar file \u5185\u7684\u6587\u4ef6\u65f6\uff0c\u5c31\u5f97\u8981\u52a0\u4e0a z \u8fd9\u4e2a\u53c2\u6570\u4e86\uff01\u8fd9\u5f88\u91cd\u8981\u7684\uff01<\/p>\n<ul>\n<li>\u8303\u4f8b\u4e09\uff1a\u5c06 \/tmp\/etc.tar.gz \u6587\u4ef6\u89e3\u538b\u7f29\u5728 \/usr\/local\/src \u5e95\u4e0b<\/li>\n<\/ul>\n<pre>[root@linux ~]# cd \/usr\/local\/src<\/pre>\n<pre>[root@linux src]# tar -zxvf \/tmp\/etc.tar.gz\r\n<\/pre>\n<p>\u5728\u9884\u8bbe\u7684\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u538b\u7f29\u6863\u5728\u4efb\u4f55\u5730\u65b9\u89e3\u5f00\u7684\uff01\u4ee5\u8fd9\u4e2a\u8303\u4f8b\u6765\u8bf4\uff0c<\/p>\n<p>\u6211\u5148\u5c06\u5de5\u4f5c\u76ee\u5f55\u53d8\u6362\u5230 \/usr\/local\/src \u5e95\u4e0b\uff0c\u5e76\u4e14\u89e3\u5f00 \/tmp\/etc.tar.gz \uff0c<\/p>\n<p>\u5219\u89e3\u5f00\u7684\u76ee\u5f55\u4f1a\u5728 \/usr\/local\/src\/etc \u5462\uff01\u53e6\u5916\uff0c\u5982\u679c\u60a8\u8fdb\u5165 \/usr\/local\/src\/etc \u5219\u4f1a\u53d1\u73b0\uff0c<\/p>\n<p>\u8be5\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\u5c5e\u6027\u4e0e \/etc\/ \u53ef\u80fd\u4f1a\u6709\u6240\u4e0d\u540c\u5594\uff01<\/p>\n<ul>\n<li>\u8303\u4f8b\u56db\uff1a\u5728 \/tmp \u5e95\u4e0b\uff0c\u6211\u53ea\u60f3\u8981\u5c06 \/tmp\/etc.tar.gz \u5185\u7684 etc\/passwd \u89e3\u5f00\u800c\u5df2<\/li>\n<\/ul>\n<pre>[root@linux ~]# cd \/tmp<\/pre>\n<pre>[root@linux tmp]# tar -zxvf \/tmp\/etc.tar.gz etc\/passwd\r\n<\/pre>\n<p>\u6211\u53ef\u4ee5\u900f\u8fc7 tar -ztvf \u6765\u67e5\u9605 tarfile \u5185\u7684\u6587\u4ef6\u540d\u79f0\uff0c\u5982\u679c\u5355\u53ea\u8981\u4e00\u4e2a\u6587\u4ef6\uff0c\u5c31\u53ef\u4ee5\u900f\u8fc7\u8fd9\u4e2a\u65b9\u5f0f\u6765\u4e0b\u8fbe\uff01<\/p>\n<p>\u6ce8\u610f\u5230\uff01 etc.tar.gz \u5185\u7684\u6839\u76ee\u5f55 \/ \u662f\u88ab\u62ff\u6389\u4e86\uff01<\/p>\n<ul>\n<li>\u8303\u4f8b\u4e94\uff1a\u5c06 \/etc\/ \u5185\u7684\u6240\u6709\u6587\u4ef6\u5907\u4efd\u4e0b\u6765\uff0c\u5e76\u4e14\u4fdd\u5b58\u5176\u6743\u9650\uff01<\/li>\n<\/ul>\n<pre>[root@linux ~]# tar -zxvpf \/tmp\/etc.tar.gz \/etc\r\n<\/pre>\n<p>\u8fd9\u4e2a -p \u7684\u5c5e\u6027\u662f\u5f88\u91cd\u8981\u7684\uff0c\u5c24\u5176\u662f\u5f53\u60a8\u8981\u4fdd\u7559\u539f\u672c\u6587\u4ef6\u7684\u5c5e\u6027\u65f6\uff01<\/p>\n<ul>\n<li>\u8303\u4f8b\u516d\uff1a\u5728 \/home \u5f53\u4e2d\uff0c\u6bd4 2005\/06\/01 \u65b0\u7684\u6587\u4ef6\u624d\u5907\u4efd<\/li>\n<\/ul>\n<pre>[root@linux ~]# tar -N '2005\/06\/01' -zcvf home.tar.gz \/home\r\n<\/pre>\n<ul>\n<li>\u8303\u4f8b\u4e03\uff1a\u6211\u8981\u5907\u4efd \/home, \/etc \uff0c\u4f46\u4e0d\u8981 \/home\/dmtsai<\/li>\n<\/ul>\n<pre>[root@linux ~]# tar --exclude \/home\/dmtsai -zcvf myfile.tar.gz \/home\/* \/etc\r\n<\/pre>\n<ul>\n<li>\u8303\u4f8b\u516b\uff1a\u5c06 \/etc\/ \u6253\u5305\u540e\u76f4\u63a5\u89e3\u5f00\u5728 \/tmp \u5e95\u4e0b\uff0c\u800c\u4e0d\u4ea7\u751f\u6587\u4ef6\uff01<\/li>\n<\/ul>\n<pre>[root@linux ~]# cd \/tmp<\/pre>\n<pre>[root@linux tmp]# tar -cvf - \/etc | tar -xvf -\r\n<\/pre>\n<p>\u8fd9\u4e2a\u52a8\u4f5c\u6709\u70b9\u50cf\u662f cp -r \/etc \/tmp \u5566\uff5e\u4f9d\u65e7\u662f\u6709\u5176\u6709\u7528\u9014\u7684\uff01\u8981\u6ce8\u610f\u7684\u5730\u65b9\u5728\u65bc\u8f93\u51fa\u6863\u53d8\u6210 &#8211;<\/p>\n<p>\u800c\u8f93\u5165\u6863\u4e5f\u53d8\u6210 &#8211; \uff0c\u53c8\u6709\u4e00\u4e2a | \u5b58\u5728\uff5e\u8fd9\u5206\u522b\u4ee3\u8868 standard output, standard input \u4e0e\u7ba1\u7ebf\u547d\u4ee4\u5566\uff01<\/p>\n<p><a name=\"gzip.2C_zcat_.E5.91.BD.E4.BB.A4\"><\/a><\/p>\n<h2><a name=\"t3\"><\/a>gzip, zcat \u547d\u4ee4<\/h2>\n<pre> [root@linux ~]# gzip [-cdt#] \u6863\u540d<\/pre>\n<pre> [root@linux ~]# zcat \u6863\u540d.gz\r\n<\/pre>\n<p><a name=\".E5.8F.82.E6.95.B0_2\"><\/a><\/p>\n<h3><a name=\"t4\"><\/a>\u53c2\u6570<\/h3>\n<dl>\n<dd>-c \uff1a\u5c06\u538b\u7f29\u7684\u8d44\u6599\u8f93\u51fa\u5230\u8424\u5e55\u4e0a\uff0c\u53ef\u900f\u8fc7\u8d44\u6599\u6d41\u91cd\u5bfc\u5411\u6765\u5904\u7406\uff1b<\/dd>\n<dd>-d \uff1a\u89e3\u538b\u7f29\u7684\u53c2\u6570\uff1b<\/dd>\n<dd>-t \uff1a\u53ef\u4ee5\u7528\u6765\u68c0\u9a8c\u4e00\u4e2a\u538b\u7f29\u6863\u7684\u4e00\u81f4\u6027\uff5e\u770b\u770b\u6587\u4ef6\u6709\u65e0\u9519\u8bef\uff1b<\/dd>\n<dd>-# \uff1a\u538b\u7f29\u7b49\u7ea7\uff0c-1 \u6700\u5feb\uff0c\u4f46\u662f\u538b\u7f29\u6bd4\u6700\u5dee\u3001-9 \u6700\u6162\uff0c\u4f46\u662f\u538b\u7f29\u6bd4\u6700\u597d\uff01\u9884\u8bbe\u662f -6 \uff5e<\/dd>\n<\/dl>\n<p><a name=\".E8.8C.83.E4.BE.8B_2\"><\/a><\/p>\n<h3><a name=\"t5\"><\/a>\u8303\u4f8b<\/h3>\n<ul>\n<li>\u8303\u4f8b\u4e00\uff1a\u5c06 \/etc\/man.config \u8907\u5236\u5230 \/tmp \uff0c\u5e76\u4e14\u4ee5 gzip \u538b\u7f29<\/li>\n<\/ul>\n<pre> [root@linux ~]# cd \/tmp<\/pre>\n<pre> [root@linux tmp]# cp \/etc\/man.config .<\/pre>\n<pre> [root@linux tmp]# gzip man.config\r\n<\/pre>\n<p>\u6b64\u65f6 man.config \u4f1a\u53d8\u6210 man.config.gz \uff01<\/p>\n<ul>\n<li>\u8303\u4f8b\u4e8c\uff1a\u5c06\u8303\u4f8b\u4e00\u7684\u6587\u4ef6\u5185\u5bb9\u8bfb\u51fa\u6765\uff01<\/li>\n<\/ul>\n<pre> [root@linux tmp]# zcat man.config.gz\r\n<\/pre>\n<p>\u6b64\u65f6\u8424\u5e55\u4e0a\u4f1a\u663e\u793a man.config.gz \u89e3\u538b\u7f29\u4e4b\u540e\u7684\u6587\u4ef6\u5185\u5bb9\uff01\uff01<\/p>\n<ul>\n<li>\u8303\u4f8b\u4e09\uff1a\u5c06\u8303\u4f8b\u4e00\u7684\u6587\u4ef6\u89e3\u538b\u7f29<\/li>\n<\/ul>\n<pre> [root@linux tmp]# gzip -d man.config.gz\r\n<\/pre>\n<ul>\n<li>\u8303\u4f8b\u56db\uff1a\u5c06\u8303\u4f8b\u4e09\u89e3\u5f00\u7684 man.config \u7528\u6700\u4f73\u7684\u538b\u7f29\u6bd4\u538b\u7f29\uff0c\u5e76\u4fdd\u7559\u539f\u672c\u7684\u6587\u4ef6<\/li>\n<\/ul>\n<pre> [root@linux tmp]# gzip -9 -c man.config &gt; man.config.gz\r\n<\/pre>\n<p><a name=\"bzip2.2C_bzcat_.E5.91.BD.E4.BB.A4\"><\/a><\/p>\n<h2><a name=\"t6\"><\/a>bzip2, bzcat \u547d\u4ee4<\/h2>\n<pre> [root@linux ~]# bzip2 [-cdz] \u6863\u540d<\/pre>\n<pre> [root@linux ~]# bzcat \u6863\u540d.bz2\r\n<\/pre>\n<p><a name=\".E5.8F.82.E6.95.B0_3\"><\/a><\/p>\n<h3><a name=\"t7\"><\/a>\u53c2\u6570<\/h3>\n<dl>\n<dd>-c \uff1a\u5c06\u538b\u7f29\u7684\u8fc7\u7a0b\u4ea7\u751f\u7684\u8d44\u6599\u8f93\u51fa\u5230\u8424\u5e55\u4e0a\uff01<\/dd>\n<dd>-d \uff1a\u89e3\u538b\u7f29\u7684\u53c2\u6570<\/dd>\n<dd>-z \uff1a\u538b\u7f29\u7684\u53c2\u6570<\/dd>\n<dd>-# \uff1a\u4e0e gzip \u540c\u6837\u7684\uff0c\u90fd\u662f\u5728\u8ba1\u7b97\u538b\u7f29\u6bd4\u7684\u53c2\u6570\uff0c -9 \u6700\u4f73\uff0c -1 \u6700\u5feb\uff01<\/dd>\n<\/dl>\n<p><a name=\".E8.8C.83.E4.BE.8B_3\"><\/a><\/p>\n<h3><a name=\"t8\"><\/a>\u8303\u4f8b<\/h3>\n<ul>\n<li>\u8303\u4f8b\u4e00\uff1a\u5c06\u521a\u521a\u7684 \/tmp\/man.config \u4ee5 bzip2 \u538b\u7f29<\/li>\n<\/ul>\n<pre> [root@linux tmp]# bzip2 -z man.config\r\n<\/pre>\n<p>\u6b64\u65f6 man.config \u4f1a\u53d8\u6210 man.config.bz2 \uff01<\/p>\n<ul>\n<li>\u8303\u4f8b\u4e8c\uff1a\u5c06\u8303\u4f8b\u4e00\u7684\u6587\u4ef6\u5185\u5bb9\u8bfb\u51fa\u6765\uff01<\/li>\n<\/ul>\n<pre> [root@linux tmp]# bzcat man.config.bz2\r\n<\/pre>\n<p>\u6b64\u65f6\u8424\u5e55\u4e0a\u4f1a\u663e\u793a man.config.bz2 \u89e3\u538b\u7f29\u4e4b\u540e\u7684\u6587\u4ef6\u5185\u5bb9\uff01\uff01<\/p>\n<ul>\n<li>\u8303\u4f8b\u4e09\uff1a\u5c06\u8303\u4f8b\u4e00\u7684\u6587\u4ef6\u89e3\u538b\u7f29<\/li>\n<\/ul>\n<pre> [root@linux tmp]# bzip2 -d man.config.bz2\r\n<\/pre>\n<ul>\n<li>\u8303\u4f8b\u56db\uff1a\u5c06\u8303\u4f8b\u4e09\u89e3\u5f00\u7684 man.config \u7528\u6700\u4f73\u7684\u538b\u7f29\u6bd4\u538b\u7f29\uff0c\u5e76\u4fdd\u7559\u539f\u672c\u7684\u6587\u4ef6<\/li>\n<\/ul>\n<pre> [root@linux tmp]# bzip2 -9 -c man.config &gt; man.config.bz2\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><a name=\"compress_.E5.91.BD.E4.BB.A4\"><\/a><\/p>\n<h2><a name=\"t9\"><\/a>compress \u547d\u4ee4<\/h2>\n<pre> [root@linux ~]# compress [-dcr] \u6587\u4ef6\u6216\u76ee\u5f55\r\n<\/pre>\n<p><a name=\".E5.8F.82.E6.95.B0_4\"><\/a><\/p>\n<h3><a name=\"t10\"><\/a>\u53c2\u6570<\/h3>\n<dl>\n<dd>-d \uff1a\u7528\u6765\u89e3\u538b\u7f29\u7684\u53c2\u6570<\/dd>\n<dd>-r \uff1a\u53ef\u4ee5\u8fde\u540c\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\u4e5f\u540c\u65f6\u7ed9\u4e88\u538b\u7f29\u5462\uff01<\/dd>\n<dd>-c \uff1a\u5c06\u538b\u7f29\u8d44\u6599\u8f93\u51fa\u6210\u4e3a standard output (\u8f93\u51fa\u5230\u8424\u5e55)<\/dd>\n<\/dl>\n<p><a name=\".E8.8C.83.E4.BE.8B_4\"><\/a><\/p>\n<h3><a name=\"t11\"><\/a>\u8303\u4f8b<\/h3>\n<ul>\n<li>\u8303\u4f8b\u4e00\uff1a\u5c06 \/etc\/man.config \u8907\u5236\u5230 \/tmp \uff0c\u5e76\u52a0\u4ee5\u538b\u7f29<\/li>\n<\/ul>\n<pre> [root@linux ~]# cd \/tmp<\/pre>\n<pre> [root@linux tmp]# cp \/etc\/man.config .<\/pre>\n<pre> [root@linux tmp]# compress man.config<\/pre>\n<pre> [root@linux tmp]# ls -l\r\n -rw-r--r-- 1 root root 2605 Jul 27 11:43 man.config.Z \r\n<\/pre>\n<ul>\n<li>\u8303\u4f8b\u4e8c\uff1a\u5c06\u521a\u521a\u7684\u538b\u7f29\u6863\u89e3\u5f00<\/li>\n<\/ul>\n<pre> [root@linux tmp]# compress -d man.config.Z\r\n<\/pre>\n<ul>\n<li>\u8303\u4f8b\u4e09\uff1a\u5c06 man.config \u538b\u7f29\u6210\u53e6\u5916\u4e00\u4e2a\u6587\u4ef6\u6765\u5907\u4efd<\/li>\n<\/ul>\n<pre> [root@linux tmp]# compress -c man.config &gt; man.config.back.Z<\/pre>\n<pre> [root@linux tmp]# ll man.config*<\/pre>\n<pre> -rw-r--r-- 1 root root 4506 Jul 27 11:43 man.config<\/pre>\n<pre> -rw-r--r-- 1 root root 2605 Jul 27 11:46 man.config.back.Z\r\n<\/pre>\n<p>\u8fd9\u4e2a -c \u7684\u53c2\u6570\u6bd4\u8f83\u6709\u8da3\uff01\u4ed6\u4f1a\u5c06\u538b\u7f29\u8fc7\u7a0b\u7684\u8d44\u6599\u8f93\u51fa\u5230\u8424\u5e55\u4e0a\uff0c\u800c\u4e0d\u662f\u5199\u5165\u6210\u4e3a file.Z \u6587\u4ef6\u3002<\/p>\n<p>\u6240\u4ee5\uff0c\u6211\u4eec\u53ef\u4ee5\u900f\u8fc7\u8d44\u6599\u6d41\u91cd\u5bfc\u5411\u7684\u65b9\u6cd5\u5c06\u8d44\u6599\u8f93\u51fa\u6210\u4e3a\u53e6\u4e00\u4e2a\u6863\u540d\u3002<\/p>\n<p>&nbsp;<\/p>\n<p><a name=\"dd_.E5.91.BD.E4.BB.A4\"><\/a><\/p>\n<h2><a name=\"t12\"><\/a>dd \u547d\u4ee4<\/h2>\n<pre> [root@linux ~]# dd if=\"input_file\" of=\"outptu_file\" bs=\"block_size\" \/ count=\"number\"\r\n<\/pre>\n<p><a name=\".E5.8F.82.E6.95.B0_5\"><\/a><\/p>\n<h3><a name=\"t13\"><\/a>\u53c2\u6570<\/h3>\n<dl>\n<dd>if \uff1a\u5c31\u662f input file \u5570\uff5e\u4e5f\u53ef\u4ee5\u662f\u88c5\u7f6e\u5594\uff01<\/dd>\n<dd>of \uff1a\u5c31\u662f output file \u5594\uff5e\u4e5f\u53ef\u4ee5\u662f\u88c5\u7f6e\uff1b<\/dd>\n<dd>bs \uff1a\u89c4\u5212\u7684\u4e00\u4e2a block \u7684\u5927\u5c0f\uff0c\u5982\u679c\u6ca1\u6709\u8bbe\u5b9a\u65f6\uff0c\u9884\u8bbe\u662f 512 bytes<\/dd>\n<dd>count\uff1a\u591a\u5c11\u4e2a bs \u7684\u610f\u601d\u3002<\/dd>\n<\/dl>\n<p><a name=\".E8.8C.83.E4.BE.8B_5\"><\/a><\/p>\n<h3><a name=\"t14\"><\/a>\u8303\u4f8b<\/h3>\n<ul>\n<li>\u8303\u4f8b\u4e00\uff1a\u5c06 \/etc\/passwd \u5907\u4efd\u5230 \/tmp\/passwd.back \u5f53\u4e2d<\/li>\n<\/ul>\n<pre> [root@linux ~]# dd if=\/etc\/passwd of=\/tmp\/passwd.back<\/pre>\n<pre> 3+1 records in<\/pre>\n<pre> 3+1 records out<\/pre>\n<pre> [root@linux ~]# ll \/etc\/passwd \/tmp\/passwd.back<\/pre>\n<pre> -rw-r--r-- 1 root root 1746 Aug 25 14:16 \/etc\/passwd<\/pre>\n<pre> -rw-r--r-- 1 root root 1746 Aug 29 16:57 \/tmp\/passwd.back\r\n<\/pre>\n<p>\u4ed4\u7ec6\u7684\u770b\u4e00\u4e0b\uff0c\u6211\u7684 \/etc\/passwd \u6587\u4ef6\u5927\u5c0f\u4e3a 1746 bytes\uff0c\u56e0\u4e3a\u6211\u6ca1\u6709\u8bbe\u5b9a bs \uff0c<\/p>\n<p>\u6240\u4ee5\u9884\u8bbe\u662f 512 bytes \u4e3a\u4e00\u4e2a\u5355\u4f4d\uff0c\u56e0\u6b64\uff0c\u4e0a\u9762\u90a3\u4e2a 3+1 \u8868\u793a\u6709 3 \u4e2a\u5b8c\u6574\u7684 512 bytes\uff0c<\/p>\n<p>\u4ee5\u53ca\u672a\u6ee1 512 bytes \u7684\u53e6\u4e00\u4e2a block \u7684\u610f\u601d\u3002\u4e8b\u5b9e\u4e0a\uff0c\u611f\u89c9\u597d\u50cf\u662f cp \u8fd9\u4e2a\u6307\u4ee4\u5566\uff5e<\/p>\n<ul>\n<li>\u8303\u4f8b\u4e8c\uff1a\u5907\u4efd \/dev\/hda \u7684 MBR<\/li>\n<\/ul>\n<pre> [root@linux ~]# dd if=\/dev\/hda of=\/tmp\/mbr.back bs=512 count=1<\/pre>\n<pre> 1+0 records in<\/pre>\n<pre> 1+0 records out\r\n<\/pre>\n<p>\u8fd9\u5c31\u5f97\u597d\u597d\u77ad\u89e3\u4e00\u4e0b\u5570\uff5e\u6211\u4eec\u77e5\u9053\u6574\u9897\u786c\u76d8\u7684 MBR \u4e3a 512 bytes\uff0c\u5c31\u662f\u653e\u5728\u786c\u76d8\u7684\u7b2c\u4e00\u4e2a sector \u5566\uff0c<\/p>\n<p>\u56e0\u6b64\uff0c\u6211\u53ef\u4ee5\u5229\u7528\u8fd9\u4e2a\u65b9\u5f0f\u6765\u5c06 MBR \u5185\u7684\u6240\u6709\u8d44\u6599\u90fd\u7eaa\u5f55\u4e0b\u6765\uff0c\u771f\u7684\u5f88\u5389\u5bb3\u5427\uff01 ^_^<\/p>\n<ul>\n<li>\u8303\u4f8b\u4e09\uff1a\u5c06\u6574\u4e2a \/dev\/hda1 partition \u5907\u4efd\u4e0b\u6765\u3002<\/li>\n<\/ul>\n<pre> [root@linux ~]# dd if=\/dev\/hda1 of=\/some\/path\/filenaem\r\n<\/pre>\n<p>\u8fd9\u4e2a\u6307\u4ee4\u5f88\u5389\u5bb3\u554a\uff01\u5c06\u6574\u4e2a partition \u7684\u5185\u5bb9\u5168\u90e8\u5907\u4efd\u4e0b\u6765\uff5e\u540e\u9762\u63a5\u7684 of \u5fc5\u987b\u8981\u4e0d\u662f\u5728 \/dev\/hda1 \u7684\u76ee\u5f55\u5185\u554a\uff5e<\/p>\n<p>\u5426\u5219\uff0c\u600e\u4e48\u8bfb\u4e5f\u8bfb\u4e0d\u5b8c\uff5e\u8fd9\u4e2a\u52a8\u4f5c\u662f\u5f88\u6709\u6548\u7528\u7684\uff0c\u5982\u679c\u6539\u5929\u4f60\u5fc5\u987b\u8981\u5b8c\u6574\u7684\u5c06\u6574\u4e2a partition \u7684\u5185\u5bb9\u586b\u56de\u53bb\uff0c<\/p>\n<p>\u5219\u53ef\u4ee5\u5229\u7528 dd if=\/some\/file of=\/dev\/hda1 \u6765\u5c06\u8d44\u6599\u5199\u5165\u5230\u786c\u76d8\u5f53\u4e2d\u3002\u5982\u679c\u60f3\u8981\u6574\u4e2a\u786c\u76d8\u5907\u4efd\u7684\u8bdd\uff0c<\/p>\n<p>\u5c31\u7c7b\u4f3c Norton \u7684 ghost \u8f6f\u4f53\u4e00\u822c\uff0c\u7531 disk \u5230 disk \uff0c\u563f\u563f\uff5e\u5229\u7528 dd \u5c31\u53ef\u4ee5\u5566\uff5e\u5389\u5bb3\u5389\u5bb3\uff01<\/p>\n<p>&nbsp;<\/p>\n<p><a name=\"cpio_.E5.91.BD.E4.BB.A4\"><\/a><\/p>\n<h2><a name=\"t15\"><\/a>cpio \u547d\u4ee4<\/h2>\n<pre> [root@linux ~]# cpio -covB &gt; [file|device] &lt;==\u5907\u4efd<\/pre>\n<pre> [root@linux ~]# cpio -icduv &lt; [file|device] &lt;==\u8fd8\u539f\r\n<\/pre>\n<p><a name=\".E5.8F.82.E6.95.B0_6\"><\/a><\/p>\n<h3><a name=\"t16\"><\/a>\u53c2\u6570<\/h3>\n<dl>\n<dd>-o \uff1a\u5c06\u8d44\u6599 copy \u8f93\u51fa\u5230\u6587\u4ef6\u6216\u88c5\u7f6e\u4e0a<\/dd>\n<dd>-i \uff1a\u5c06\u8d44\u6599\u81ea\u6587\u4ef6\u6216\u88c5\u7f6e copy \u51fa\u6765\u7cfb\u7edf\u5f53\u4e2d<\/dd>\n<dd>-t \uff1a\u67e5\u770b cpio \u5efa\u7acb\u7684\u6587\u4ef6\u6216\u88c5\u7f6e\u7684\u5185\u5bb9<\/dd>\n<dd>-c \uff1a\u4e00\u79cd\u8f83\u65b0\u7684 portable format \u65b9\u5f0f\u50a8\u5b58<\/dd>\n<dd>-v \uff1a\u8ba9\u50a8\u5b58\u7684\u8fc7\u7a0b\u4e2d\u6587\u4ef6\u540d\u79f0\u53ef\u4ee5\u5728\u8424\u5e55\u4e0a\u663e\u793a<\/dd>\n<dd>-B \uff1a\u8ba9\u9884\u8bbe\u7684 Blocks \u53ef\u4ee5\u589e\u52a0\u81f3 5120 bytes \uff0c\u9884\u8bbe\u662f 512 bytes \uff01<\/dd>\n<dd>\u8fd9\u6837\u7684\u597d\u5904\u662f\u53ef\u4ee5\u8ba9\u5927\u6587\u4ef6\u7684\u50a8\u5b58\u901f\u5ea6\u52a0\u5feb(\u8bf7\u53c2\u8003 i-nodes \u7684\u89c2\u5ff5)<\/dd>\n<dd>-d \uff1a\u81ea\u52a8\u5efa\u7acb\u76ee\u5f55\uff01\u7531\u65bc cpio \u7684\u5185\u5bb9\u53ef\u80fd\u4e0d\u662f\u5728\u540c\u4e00\u4e2a\u76ee\u5f55\u5185\uff0c\u5982\u6b64\u7684\u8bdd\u5728\u53cd\u5907\u4efd\u7684\u8fc7\u7a0b\u4f1a\u6709\u95ee\u9898\uff01<\/dd>\n<dd>\u8fd9\u4e2a\u65f6\u5019\u52a0\u4e0a -d \u7684\u8bdd\uff0c\u5c31\u53ef\u4ee5\u81ea\u52a8\u7684\u5c06\u9700\u8981\u7684\u76ee\u5f55\u5efa\u7acb\u8d77\u6765\u4e86\uff01<\/dd>\n<dd>-u \uff1a\u81ea\u52a8\u7684\u5c06\u8f83\u65b0\u7684\u6587\u4ef6\u8986\u76d6\u8f83\u65e7\u7684\u6587\u4ef6\uff01<\/dd>\n<\/dl>\n<p><a name=\".E8.8C.83.E4.BE.8B_6\"><\/a><\/p>\n<h3><a name=\"t17\"><\/a>\u8303\u4f8b<\/h3>\n<ul>\n<li>\u8303\u4f8b\u4e00\uff1a\u5c06\u6240\u6709\u7cfb\u7edf\u4e0a\u7684\u8d44\u6599\u901a\u901a\u5199\u5165\u78c1\u5e26\u673a\u5185\uff01<\/li>\n<\/ul>\n<pre> [root@linux ~]# find \/ -print | cpio -covB &gt; \/dev\/st0\r\n<\/pre>\n<p>\u4e00\u822c\u6765\u8bf4\uff0c\u4f7f\u7528 SCSI \u4ecb\u9762\u7684\u78c1\u5e26\u673a\uff0c\u4ee3\u53f7\u662f \/dev\/st0 \u5594\uff01<\/p>\n<ul>\n<li>\u8303\u4f8b\u4e8c\uff1a\u68c0\u67e5\u78c1\u5e26\u673a\u4e0a\u9762\u6709\u4ec0\u4e48\u6587\u4ef6\uff1f<\/li>\n<\/ul>\n<pre> [root@linux ~]# cpio -icdvt &lt; \/dev\/st0<\/pre>\n<pre> [root@linux ~]# cpio -icdvt &lt; \/dev\/st0 &gt; \/tmp\/content\r\n<\/pre>\n<p>\u7b2c\u4e00\u4e2a\u52a8\u4f5c\u5f53\u4e2d\uff0c\u4f1a\u5c06\u78c1\u5e26\u673a\u5185\u7684\u6863\u540d\u5217\u51fa\u5230\u8424\u5e55\u4e0a\u9762\uff0c\u800c\u6211\u4eec\u53ef\u4ee5\u900f\u8fc7\u7b2c\u4e8c\u4e2a\u52a8\u4f5c\uff0c\u5c06\u6240\u6709\u7684\u6863\u540d\u901a\u901a\u7eaa\u5f55\u5230 \/tmp\/content \u6587\u4ef6\u53bb\uff01<\/p>\n<ul>\n<li>\u8303\u4f8b\u4e09\uff1a\u5c06\u78c1\u5e26\u4e0a\u7684\u8d44\u6599\u8fd8\u539f\u56de\u6765\uff5e<\/li>\n<\/ul>\n<pre> [root@linux ~]# cpio -icduv &lt; \/dev\/st0\r\n<\/pre>\n<p>\u4e00\u822c\u6765\u8bf4\uff0c\u4f7f\u7528 SCSI \u4ecb\u9762\u7684\u78c1\u5e26\u673a\uff0c\u4ee3\u53f7\u662f \/dev\/st0 \u5594\uff01<\/p>\n<ul>\n<li>\u8303\u4f8b\u56db\uff1a\u5c06 \/etc \u5e95\u4e0b\u7684\u6240\u6709\u300e\u6587\u4ef6\u300f\u90fd\u5907\u4efd\u5230 \/root\/etc.cpio \u4e2d\uff01<\/li>\n<\/ul>\n<pre> [root@linux ~]# find \/etc -type f | cpio -o &gt; \/root\/etc.cpio\r\n<\/pre>\n<p>\u8fd9\u6837\u5c31\u80fd\u591f\u5907\u4efd\u5570\uff5e\u60a8\u4e5f\u53ef\u4ee5\u5c06\u8d44\u6599\u4ee5 cpio -i &lt; \/root\/etc.cpio \u6765\u5c06\u8d44\u6599\u6349\u51fa\u6765\uff01\uff01\uff01\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>tar\u547d\u4ee4 [root@linux ~]# tar [-cxtzjvfpPN] &#8230;<br \/><a class=\"read-more-button\" href=\"https:\/\/freesilo.com\/?p=507\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-507","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/posts\/507","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/freesilo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=507"}],"version-history":[{"count":1,"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/posts\/507\/revisions"}],"predecessor-version":[{"id":508,"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/posts\/507\/revisions\/508"}],"wp:attachment":[{"href":"https:\/\/freesilo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=507"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/freesilo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=507"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/freesilo.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=507"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}