{"id":270,"date":"2018-11-21T19:46:05","date_gmt":"2018-11-21T11:46:05","guid":{"rendered":"https:\/\/www.ccagml.com\/?p=270"},"modified":"2019-02-21T10:13:42","modified_gmt":"2019-02-21T02:13:42","slug":"linux%e5%9f%ba%e7%a1%80%e7%9f%a5%e8%af%86","status":"publish","type":"post","link":"https:\/\/www.ccagml.com\/?p=270","title":{"rendered":"Linux\u57fa\u7840\u77e5\u8bc6"},"content":{"rendered":"<ul>\n<li><a href=\"https:\/\/github.com\/CyC2018\" target=\"_blank\" rel=\"noopener\">\u53c2\u8003 <\/a><\/li>\n<\/ul>\n<h1>\u4e00\u3001\u5e38\u7528\u64cd\u4f5c\u4ee5\u53ca\u6982\u5ff5<\/h1>\n<h2>\u5feb\u6377\u952e<\/h2>\n<ul>\n<li>Tab\uff1a\u547d\u4ee4\u548c\u6587\u4ef6\u540d\u8865\u5168\uff1b<\/li>\n<li>Ctrl+C\uff1a\u4e2d\u65ad\u6b63\u5728\u8fd0\u884c\u7684\u7a0b\u5e8f\uff1b<\/li>\n<li>Ctrl+D\uff1a\u7ed3\u675f\u952e\u76d8\u8f93\u5165\uff08End Of File\uff0cEOF\uff09<\/li>\n<\/ul>\n<h2>\u6c42\u52a9<\/h2>\n<h3>1. &#8211;help<\/h3>\n<p>\u6307\u4ee4\u7684\u57fa\u672c\u7528\u6cd5\u4e0e\u9009\u9879\u4ecb\u7ecd\u3002<\/p>\n<h3>2. man<\/h3>\n<p>man \u662f manual \u7684\u7f29\u5199\uff0c\u5c06\u6307\u4ee4\u7684\u5177\u4f53\u4fe1\u606f\u663e\u793a\u51fa\u6765\u3002<\/p>\n<p>\u5f53\u6267\u884c<code>man date<\/code>\u65f6\uff0c\u6709 DATE(1) \u51fa\u73b0\uff0c\u5176\u4e2d\u7684\u6570\u5b57\u4ee3\u8868\u6307\u4ee4\u7684\u7c7b\u578b\uff0c\u5e38\u7528\u7684\u6570\u5b57\u53ca\u5176\u7c7b\u578b\u5982\u4e0b\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th align=\"center\">\u4ee3\u53f7<\/th>\n<th>\u7c7b\u578b<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td align=\"center\">1<\/td>\n<td>\u7528\u6237\u5728 shell \u73af\u5883\u4e2d\u53ef\u4ee5\u64cd\u4f5c\u7684\u6307\u4ee4\u6216\u8005\u53ef\u6267\u884c\u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">5<\/td>\n<td>\u914d\u7f6e\u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">8<\/td>\n<td>\u7cfb\u7edf\u7ba1\u7406\u5458\u53ef\u4ee5\u4f7f\u7528\u7684\u7ba1\u7406\u6307\u4ee4<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>3. info<\/h3>\n<p>info \u4e0e man \u7c7b\u4f3c\uff0c\u4f46\u662f info \u5c06\u6587\u6863\u5206\u6210\u4e00\u4e2a\u4e2a\u9875\u9762\uff0c\u6bcf\u4e2a\u9875\u9762\u53ef\u4ee5\u8fdb\u884c\u8df3\u8f6c\u3002<\/p>\n<h3>4. doc<\/h3>\n<p>\/usr\/share\/doc \u5b58\u653e\u7740\u8f6f\u4ef6\u7684\u4e00\u6574\u5957\u8bf4\u660e\u6587\u4ef6\u3002<\/p>\n<h2>\u5173\u673a<\/h2>\n<h3>1. who<\/h3>\n<p>\u5728\u5173\u673a\u524d\u9700\u8981\u5148\u4f7f\u7528 who \u547d\u4ee4\u67e5\u770b\u6709\u6ca1\u6709\u5176\u5b83\u7528\u6237\u5728\u7ebf\u3002<\/p>\n<h3>2. sync<\/h3>\n<p>\u4e3a\u4e86\u52a0\u5feb\u5bf9\u78c1\u76d8\u6587\u4ef6\u7684\u8bfb\u5199\u901f\u5ea6\uff0c\u4f4d\u4e8e\u5185\u5b58\u4e2d\u7684\u6587\u4ef6\u6570\u636e\u4e0d\u4f1a\u7acb\u5373\u540c\u6b65\u5230\u78c1\u76d8\u4e0a\uff0c\u56e0\u6b64\u5173\u673a\u4e4b\u524d\u9700\u8981\u5148\u8fdb\u884c sync \u540c\u6b65\u64cd\u4f5c\u3002<\/p>\n<h3>3. shutdown<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n# shutdown [-krhc] \u65f6\u95f4 [\u4fe1\u606f]\n-k \uff1a \u4e0d\u4f1a\u5173\u673a\uff0c\u53ea\u662f\u53d1\u9001\u8b66\u544a\u4fe1\u606f\uff0c\u901a\u77e5\u6240\u6709\u5728\u7ebf\u7684\u7528\u6237\n-r \uff1a \u5c06\u7cfb\u7edf\u7684\u670d\u52a1\u505c\u6389\u540e\u5c31\u91cd\u65b0\u542f\u52a8\n-h \uff1a \u5c06\u7cfb\u7edf\u7684\u670d\u52a1\u505c\u6389\u540e\u5c31\u7acb\u5373\u5173\u673a\n-c \uff1a \u53d6\u6d88\u5df2\u7ecf\u5728\u8fdb\u884c\u7684 shutdown \u6307\u4ee4\u5185\u5bb9\n<\/pre>\n<h2>PATH<\/h2>\n<p>\u53ef\u4ee5\u5728\u73af\u5883\u53d8\u91cf PATH \u4e2d\u58f0\u660e\u53ef\u6267\u884c\u6587\u4ef6\u7684\u8def\u5f84\uff0c\u8def\u5f84\u4e4b\u95f4\u7528 : \u5206\u9694\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n\/usr\/local\/bin:\/usr\/bin:\/usr\/local\/sbin:\/usr\/sbin:\/home\/dmtsai\/.local\/bin:\/home\/dmtsai\/bin\n<\/pre>\n<h2>sudo<\/h2>\n<p>sudo \u5141\u8bb8\u4e00\u822c\u7528\u6237\u4f7f\u7528 root \u53ef\u6267\u884c\u7684\u547d\u4ee4\uff0c\u4e0d\u8fc7\u53ea\u6709\u5728 \/etc\/sudoers \u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0\u7684\u7528\u6237\u624d\u80fd\u4f7f\u7528\u8be5\u6307\u4ee4\u3002<\/p>\n<h2>\u5305\u7ba1\u7406\u5de5\u5177<\/h2>\n<p>RPM \u548c DPKG \u4e3a\u6700\u5e38\u89c1\u7684\u4e24\u7c7b\u8f6f\u4ef6\u5305\u7ba1\u7406\u5de5\u5177\uff1a<\/p>\n<ul>\n<li>RPM \u5168\u79f0\u4e3a Redhat Package Manager\uff0c\u6700\u65e9\u7531 Red Hat \u516c\u53f8\u5236\u5b9a\u5b9e\u65bd\uff0c\u968f\u540e\u88ab GNU \u5f00\u6e90\u64cd\u4f5c\u7cfb\u7edf\u63a5\u53d7\u5e76\u6210\u4e3a\u5f88\u591a Linux \u7cfb\u7edf (RHEL) \u7684\u65e2\u5b9a\u8f6f\u4ef6\u6807\u51c6\u3002<\/li>\n<li>\u4e0e RPM \u8fdb\u884c\u7ade\u4e89\u7684\u662f\u57fa\u4e8e Debian \u64cd\u4f5c\u7cfb\u7edf (Ubuntu) \u7684 DEB \u8f6f\u4ef6\u5305\u7ba1\u7406\u5de5\u5177 DPKG\uff0c\u5168\u79f0\u4e3a Debian Package\uff0c\u529f\u80fd\u65b9\u9762\u4e0e RPM \u76f8\u4f3c\u3002<\/li>\n<\/ul>\n<p>YUM \u57fa\u4e8e RPM\uff0c\u5177\u6709\u4f9d\u8d56\u7ba1\u7406\u529f\u80fd\uff0c\u5e76\u5177\u6709\u8f6f\u4ef6\u5347\u7ea7\u7684\u529f\u80fd\u3002<\/p>\n<h2>\u53d1\u884c\u7248<\/h2>\n<p>Linux \u53d1\u884c\u7248\u662f Linux \u5185\u6838\u53ca\u5404\u79cd\u5e94\u7528\u8f6f\u4ef6\u7684\u96c6\u6210\u7248\u672c\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th align=\"center\">\u57fa\u4e8e\u7684\u5305\u7ba1\u7406\u5de5\u5177<\/th>\n<th align=\"center\">\u5546\u4e1a\u53d1\u884c\u7248<\/th>\n<th align=\"center\">\u793e\u533a\u53d1\u884c\u7248<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td align=\"center\">RPM<\/td>\n<td align=\"center\">Red Hat<\/td>\n<td align=\"center\">Fedora \/ CentOS<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">DPKG<\/td>\n<td align=\"center\">Ubuntu<\/td>\n<td align=\"center\">Debian<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>VIM \u4e09\u4e2a\u6a21\u5f0f<\/h2>\n<ul>\n<li>\u4e00\u822c\u6307\u4ee4\u6a21\u5f0f\uff08Command mode\uff09\uff1aVIM \u7684\u9ed8\u8ba4\u6a21\u5f0f\uff0c\u53ef\u4ee5\u7528\u4e8e\u79fb\u52a8\u6e38\u6807\u67e5\u770b\u5185\u5bb9\uff1b<\/li>\n<li>\u7f16\u8f91\u6a21\u5f0f\uff08Insert mode\uff09\uff1a\u6309\u4e0b &#8220;i&#8221; \u7b49\u6309\u952e\u4e4b\u540e\u8fdb\u5165\uff0c\u53ef\u4ee5\u5bf9\u6587\u672c\u8fdb\u884c\u7f16\u8f91\uff1b<\/li>\n<li>\u6307\u4ee4\u5217\u6a21\u5f0f\uff08Bottom-line mode\uff09\uff1a\u6309\u4e0b &#8220;:&#8221; \u6309\u952e\u4e4b\u540e\u8fdb\u5165\uff0c\u7528\u4e8e\u4fdd\u5b58\u9000\u51fa\u7b49\u64cd\u4f5c\u3002<\/li>\n<\/ul>\n<div align=\"center\"> <img src=\"pics\/5942debd-fc00-477a-b390-7c5692cc8070.jpg\" width=\"400\"\/> <\/div>\n<p><\/p>\n<p>\u5728\u6307\u4ee4\u5217\u6a21\u5f0f\u4e0b\uff0c\u6709\u4ee5\u4e0b\u547d\u4ee4\u7528\u4e8e\u79bb\u5f00\u6216\u8005\u4fdd\u5b58\u6587\u4ef6\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th align=\"center\">\u547d\u4ee4<\/th>\n<th align=\"center\">\u4f5c\u7528<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td align=\"center\">:w<\/td>\n<td align=\"center\">\u5199\u5165\u78c1\u76d8<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">:w!<\/td>\n<td align=\"center\">\u5f53\u6587\u4ef6\u4e3a\u53ea\u8bfb\u65f6\uff0c\u5f3a\u5236\u5199\u5165\u78c1\u76d8\u3002\u5230\u5e95\u80fd\u4e0d\u80fd\u5199\u5165\uff0c\u4e0e\u7528\u6237\u5bf9\u8be5\u6587\u4ef6\u7684\u6743\u9650\u6709\u5173<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">:q<\/td>\n<td align=\"center\">\u79bb\u5f00<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">:q!<\/td>\n<td align=\"center\">\u5f3a\u5236\u79bb\u5f00\u4e0d\u4fdd\u5b58<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">:wq<\/td>\n<td align=\"center\">\u5199\u5165\u78c1\u76d8\u540e\u79bb\u5f00<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">:wq!<\/td>\n<td align=\"center\">\u5f3a\u5236\u5199\u5165\u78c1\u76d8\u540e\u79bb\u5f00<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>GNU<\/h2>\n<p>GNU \u8ba1\u5212\uff0c\u8bd1\u4e3a\u9769\u5974\u8ba1\u5212\uff0c\u5b83\u7684\u76ee\u6807\u662f\u521b\u5efa\u4e00\u5957\u5b8c\u5168\u81ea\u7531\u7684\u64cd\u4f5c\u7cfb\u7edf\uff0c\u79f0\u4e3a GNU\uff0c\u5176\u5185\u5bb9\u8f6f\u4ef6\u5b8c\u5168\u4ee5 GPL \u65b9\u5f0f\u53d1\u5e03\u3002\u5176\u4e2d GPL \u5168\u79f0\u4e3a GNU \u901a\u7528\u516c\u5171\u8bb8\u53ef\u534f\u8bae\uff0c\u5305\u542b\u4e86\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<ul>\n<li>\u4ee5\u4efb\u4f55\u76ee\u7684\u8fd0\u884c\u6b64\u7a0b\u5e8f\u7684\u81ea\u7531\uff1b<\/li>\n<li>\u518d\u590d\u5236\u7684\u81ea\u7531\uff1b<\/li>\n<li>\u6539\u8fdb\u6b64\u7a0b\u5e8f\uff0c\u5e76\u516c\u5f00\u53d1\u5e03\u6539\u8fdb\u7684\u81ea\u7531\u3002<\/li>\n<\/ul>\n<h2>\u5f00\u6e90\u534f\u8bae<\/h2>\n<ul>\n<li><a href=\"https:\/\/choosealicense.com\/\" target=\"_blank\" rel=\"noopener\">Choose an open source license<\/a><\/li>\n<li><a href=\"http:\/\/www.ruanyifeng.com\/blog\/2011\/05\/how_to_choose_free_software_licenses.html\" target=\"_blank\" rel=\"noopener\">\u5982\u4f55\u9009\u62e9\u5f00\u6e90\u8bb8\u53ef\u8bc1\uff1f<\/a><\/li>\n<\/ul>\n<h1>\u4e8c\u3001\u78c1\u76d8<\/h1>\n<h2>\u78c1\u76d8\u63a5\u53e3<\/h2>\n<h3>1. IDE<\/h3>\n<p>IDE\uff08ATA\uff09\u5168\u79f0 Advanced Technology Attachment\uff0c\u63a5\u53e3\u901f\u5ea6\u6700\u5927\u4e3a 133MB\/s\uff0c\u56e0\u4e3a\u5e76\u53e3\u7ebf\u7684\u6297\u5e72\u6270\u6027\u592a\u5dee\uff0c\u4e14\u6392\u7ebf\u5360\u7528\u7a7a\u95f4\u8f83\u5927\uff0c\u4e0d\u5229\u7535\u8111\u5185\u90e8\u6563\u70ed\uff0c\u5df2\u9010\u6e10\u88ab SATA \u6240\u53d6\u4ee3\u3002<\/p>\n<div align=\"center\"> <img src=\"pics\/924914c0-660c-4e4a-bbc0-1df1146e7516.jpg\" width=\"400\"\/> <\/div>\n<p><\/p>\n<h3>2. SATA<\/h3>\n<p>SATA \u5168\u79f0 Serial ATA\uff0c\u4e5f\u5c31\u662f\u4f7f\u7528\u4e32\u53e3\u7684 ATA \u63a5\u53e3\uff0c\u6297\u5e72\u6270\u6027\u5f3a\uff0c\u4e14\u5bf9\u6570\u636e\u7ebf\u7684\u957f\u5ea6\u8981\u6c42\u6bd4 ATA \u4f4e\u5f88\u591a\uff0c\u652f\u6301\u70ed\u63d2\u62d4\u7b49\u529f\u80fd\u3002SATA-II \u7684\u63a5\u53e3\u901f\u5ea6\u4e3a 300MiB\/s\uff0c\u800c\u65b0\u7684 SATA-III \u6807\u51c6\u53ef\u8fbe\u5230 600MiB\/s \u7684\u4f20\u8f93\u901f\u5ea6\u3002SATA \u7684\u6570\u636e\u7ebf\u4e5f\u6bd4 ATA \u7684\u7ec6\u5f97\u591a\uff0c\u6709\u5229\u4e8e\u673a\u7bb1\u5185\u7684\u7a7a\u6c14\u6d41\u901a\uff0c\u6574\u7406\u7ebf\u6750\u4e5f\u6bd4\u8f83\u65b9\u4fbf\u3002<\/p>\n<div align=\"center\"> <img src=\"pics\/f9f2a16b-4843-44d1-9759-c745772e9bcf.jpg\" width=\"\"\/> <\/div>\n<p><\/p>\n<h3>3. SCSI<\/h3>\n<p>SCSI \u5168\u79f0\u662f Small Computer System Interface\uff08\u5c0f\u578b\u673a\u7cfb\u7edf\u63a5\u53e3\uff09\uff0c\u7ecf\u5386\u591a\u4ee3\u7684\u53d1\u5c55\uff0c\u4ece\u65e9\u671f\u7684 SCSI-II \u5230\u76ee\u524d\u7684 Ultra320 SCSI \u4ee5\u53ca Fiber-Channel\uff08\u5149\u7ea4\u901a\u9053\uff09\uff0c\u63a5\u53e3\u578b\u5f0f\u4e5f\u591a\u79cd\u591a\u6837\u3002SCSI \u786c\u76d8\u5e7f\u4e3a\u5de5\u4f5c\u7ad9\u7ea7\u4e2a\u4eba\u7535\u8111\u4ee5\u53ca\u670d\u52a1\u5668\u6240\u4f7f\u7528\uff0c\u56e0\u6b64\u4f1a\u4f7f\u7528\u8f83\u4e3a\u5148\u8fdb\u7684\u6280\u672f\uff0c\u5982\u789f\u7247\u8f6c\u901f 15000rpm \u7684\u9ad8\u8f6c\u901f\uff0c\u4e14\u4f20\u8f93\u65f6 CPU \u5360\u7528\u7387\u8f83\u4f4e\uff0c\u4f46\u662f\u5355\u4ef7\u4e5f\u6bd4\u76f8\u540c\u5bb9\u91cf\u7684 ATA \u53ca SATA \u786c\u76d8\u66f4\u52a0\u6602\u8d35\u3002<\/p>\n<div align=\"center\"> <img src=\"pics\/f0574025-c514-49f5-a591-6d6a71f271f7.jpg\" width=\"\"\/> <\/div>\n<p><\/p>\n<h3>4. SAS<\/h3>\n<p>SAS\uff08Serial Attached SCSI\uff09\u662f\u65b0\u4e00\u4ee3\u7684 SCSI \u6280\u672f\uff0c\u548c SATA \u786c\u76d8\u76f8\u540c\uff0c\u90fd\u662f\u91c7\u53d6\u5e8f\u5217\u5f0f\u6280\u672f\u4ee5\u83b7\u5f97\u66f4\u9ad8\u7684\u4f20\u8f93\u901f\u5ea6\uff0c\u53ef\u8fbe\u5230 6Gb\/s\u3002\u6b64\u5916\u4e5f\u900f\u8fc7\u7f29\u5c0f\u8fde\u63a5\u7ebf\u6539\u5584\u7cfb\u7edf\u5185\u90e8\u7a7a\u95f4\u7b49\u3002<\/p>\n<div align=\"center\"> <img src=\"pics\/6729baa0-57d7-4817-b3aa-518cbccf824c.jpg\" width=\"\"\/> <\/div>\n<p><\/p>\n<h2>\u78c1\u76d8\u7684\u6587\u4ef6\u540d<\/h2>\n<p>Linux \u4e2d\u6bcf\u4e2a\u786c\u4ef6\u90fd\u88ab\u5f53\u505a\u4e00\u4e2a\u6587\u4ef6\uff0c\u5305\u62ec\u78c1\u76d8\u3002\u78c1\u76d8\u4ee5\u78c1\u76d8\u63a5\u53e3\u7c7b\u578b\u8fdb\u884c\u547d\u540d\uff0c\u5e38\u89c1\u78c1\u76d8\u7684\u6587\u4ef6\u540d\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li>IDE \u78c1\u76d8\uff1a\/dev\/hd[a-d]<\/li>\n<li>SATA\/SCSI\/SAS \u78c1\u76d8\uff1a\/dev\/sd[a-p]<\/li>\n<\/ul>\n<p>\u5176\u4e2d\u6587\u4ef6\u540d\u540e\u9762\u7684\u5e8f\u53f7\u7684\u786e\u5b9a\u4e0e\u7cfb\u7edf\u68c0\u6d4b\u5230\u78c1\u76d8\u7684\u987a\u5e8f\u6709\u5173\uff0c\u800c\u4e0e\u78c1\u76d8\u6240\u63d2\u5165\u7684\u63d2\u69fd\u4f4d\u7f6e\u65e0\u5173\u3002<\/p>\n<h1>\u4e09\u3001\u5206\u533a<\/h1>\n<h2>\u5206\u533a\u8868<\/h2>\n<p>\u78c1\u76d8\u5206\u533a\u8868\u4e3b\u8981\u6709\u4e24\u79cd\u683c\u5f0f\uff0c\u4e00\u79cd\u662f\u9650\u5236\u8f83\u591a\u7684 MBR \u5206\u533a\u8868\uff0c\u4e00\u79cd\u662f\u8f83\u65b0\u4e14\u9650\u5236\u8f83\u5c11\u7684 GPT \u5206\u533a\u8868\u3002<\/p>\n<h3>1. MBR<\/h3>\n<p>MBR \u4e2d\uff0c\u7b2c\u4e00\u4e2a\u6247\u533a\u6700\u91cd\u8981\uff0c\u91cc\u9762\u6709\u4e3b\u8981\u5f00\u673a\u8bb0\u5f55\uff08Master boot record, MBR\uff09\u53ca\u5206\u533a\u8868\uff08partition table\uff09\uff0c\u5176\u4e2d\u4e3b\u8981\u5f00\u673a\u8bb0\u5f55\u5360 446 bytes\uff0c\u5206\u533a\u8868\u5360 64 bytes\u3002<\/p>\n<p>\u5206\u533a\u8868\u53ea\u6709 64 bytes\uff0c\u6700\u591a\u53ea\u80fd\u5b58\u50a8 4 \u4e2a\u5206\u533a\uff0c\u8fd9 4 \u4e2a\u5206\u533a\u4e3a\u4e3b\u5206\u533a\uff08Primary\uff09\u548c\u6269\u5c55\u5206\u533a\uff08Extended\uff09\u3002\u5176\u4e2d\u6269\u5c55\u5206\u533a\u53ea\u6709\u4e00\u4e2a\uff0c\u5b83\u4f7f\u7528\u5176\u5b83\u6247\u533a\u7528\u8bb0\u5f55\u989d\u5916\u7684\u5206\u533a\u8868\uff0c\u56e0\u6b64\u901a\u8fc7\u6269\u5c55\u5206\u533a\u53ef\u4ee5\u5206\u51fa\u66f4\u591a\u5206\u533a\uff0c\u8fd9\u4e9b\u5206\u533a\u79f0\u4e3a\u903b\u8f91\u5206\u533a\u3002<\/p>\n<p>Linux \u4e5f\u628a\u5206\u533a\u5f53\u6210\u6587\u4ef6\uff0c\u5206\u533a\u6587\u4ef6\u7684\u547d\u540d\u65b9\u5f0f\u4e3a\uff1a\u78c1\u76d8\u6587\u4ef6\u540d + \u7f16\u53f7\uff0c\u4f8b\u5982 \/dev\/sda1\u3002\u6ce8\u610f\uff0c\u903b\u8f91\u5206\u533a\u7684\u7f16\u53f7\u4ece 5 \u5f00\u59cb\u3002<\/p>\n<h3>2. GPT<\/h3>\n<p>\u4e0d\u540c\u7684\u78c1\u76d8\u6709\u4e0d\u540c\u7684\u6247\u533a\u5927\u5c0f\uff0c\u4f8b\u5982 512 bytes \u548c\u6700\u65b0\u78c1\u76d8\u7684 4 k\u3002GPT \u4e3a\u4e86\u517c\u5bb9\u6240\u6709\u78c1\u76d8\uff0c\u5728\u5b9a\u4e49\u6247\u533a\u4e0a\u4f7f\u7528\u903b\u8f91\u533a\u5757\u5730\u5740\uff08Logical Block Address, LBA\uff09\uff0cLBA \u9ed8\u8ba4\u5927\u5c0f\u4e3a 512 bytes\u3002<\/p>\n<p>GPT \u7b2c 1 \u4e2a\u533a\u5757\u8bb0\u5f55\u4e86\u4e3b\u8981\u5f00\u673a\u8bb0\u5f55\uff08MBR\uff09\uff0c\u7d27\u63a5\u7740\u662f 33 \u4e2a\u533a\u5757\u8bb0\u5f55\u5206\u533a\u4fe1\u606f\uff0c\u5e76\u628a\u6700\u540e\u7684 33 \u4e2a\u533a\u5757\u7528\u4e8e\u5bf9\u5206\u533a\u4fe1\u606f\u8fdb\u884c\u5907\u4efd\u3002\u8fd9 33 \u4e2a\u533a\u5757\u7b2c\u4e00\u4e2a\u4e3a GPT \u8868\u5934\u7eaa\u5f55\uff0c\u8fd9\u4e2a\u90e8\u4efd\u7eaa\u5f55\u4e86\u5206\u533a\u8868\u672c\u8eab\u7684\u4f4d\u7f6e\u4e0e\u5927\u5c0f\u548c\u5907\u4efd\u5206\u533a\u7684\u4f4d\u7f6e\uff0c\u540c\u65f6\u653e\u7f6e\u4e86\u5206\u533a\u8868\u7684\u6821\u9a8c\u7801 (CRC32)\uff0c\u64cd\u4f5c\u7cfb\u7edf\u53ef\u4ee5\u6839\u636e\u8fd9\u4e2a\u6821\u9a8c\u7801\u6765\u5224\u65ad GPT \u662f\u5426\u6b63\u786e\u3002\u82e5\u6709\u9519\u8bef\uff0c\u53ef\u4ee5\u4f7f\u7528\u5907\u4efd\u5206\u533a\u8fdb\u884c\u6062\u590d\u3002<\/p>\n<p>GPT \u6ca1\u6709\u6269\u5c55\u5206\u533a\u6982\u5ff5\uff0c\u90fd\u662f\u4e3b\u5206\u533a\uff0c\u6bcf\u4e2a LAB \u53ef\u4ee5\u5206 4 \u4e2a\u5206\u533a\uff0c\u56e0\u6b64\u603b\u5171\u53ef\u4ee5\u5206 4 * 32 = 128 \u4e2a\u5206\u533a\u3002<\/p>\n<p>MBR \u4e0d\u652f\u6301 2.2 TB \u4ee5\u4e0a\u7684\u786c\u76d8\uff0cGPT \u5219\u6700\u591a\u652f\u6301\u5230 2<sup>33<\/sup> TB = 8 ZB\u3002<\/p>\n<div align=\"center\"> <img src=\"pics\/GUID_Partition_Table_Scheme.svg.png\" width=\"400\"\/> <\/div>\n<p><\/p>\n<h2>\u5f00\u673a\u68c0\u6d4b\u7a0b\u5e8f<\/h2>\n<h3>1. BIOS<\/h3>\n<p>BIOS\uff08Basic Input\/Output System\uff0c\u57fa\u672c\u8f93\u5165\u8f93\u51fa\u7cfb\u7edf\uff09\uff0c\u5b83\u662f\u4e00\u4e2a\u56fa\u4ef6\uff08\u5d4c\u5165\u5728\u786c\u4ef6\u4e2d\u7684\u8f6f\u4ef6\uff09\uff0cBIOS \u7a0b\u5e8f\u5b58\u653e\u5728\u65ad\u7535\u540e\u5185\u5bb9\u4e0d\u4f1a\u4e22\u5931\u7684\u53ea\u8bfb\u5185\u5b58\u4e2d\u3002<\/p>\n<div align=\"center\"> <img src=\"pics\/50831a6f-2777-46ea-a571-29f23c85cc21.jpg\"\/> <\/div>\n<p><\/p>\n<p>BIOS \u662f\u5f00\u673a\u7684\u65f6\u5019\u8ba1\u7b97\u673a\u6267\u884c\u7684\u7b2c\u4e00\u4e2a\u7a0b\u5e8f\uff0c\u8fd9\u4e2a\u7a0b\u5e8f\u77e5\u9053\u53ef\u4ee5\u5f00\u673a\u7684\u78c1\u76d8\uff0c\u5e76\u8bfb\u53d6\u78c1\u76d8\u7b2c\u4e00\u4e2a\u6247\u533a\u7684\u4e3b\u8981\u5f00\u673a\u8bb0\u5f55\uff08MBR\uff09\uff0c\u7531\u4e3b\u8981\u5f00\u673a\u8bb0\u5f55\uff08MBR\uff09\u6267\u884c\u5176\u4e2d\u7684\u5f00\u673a\u7ba1\u7406\u7a0b\u5e8f\uff0c\u8fd9\u4e2a\u5f00\u673a\u7ba1\u7406\u7a0b\u5e8f\u4f1a\u52a0\u8f7d\u64cd\u4f5c\u7cfb\u7edf\u7684\u6838\u5fc3\u6587\u4ef6\u3002<\/p>\n<p>\u4e3b\u8981\u5f00\u673a\u8bb0\u5f55\uff08MBR\uff09\u4e2d\u7684\u5f00\u673a\u7ba1\u7406\u7a0b\u5e8f\u63d0\u4f9b\u4ee5\u4e0b\u529f\u80fd\uff1a\u9009\u5355\u3001\u8f7d\u5165\u6838\u5fc3\u6587\u4ef6\u4ee5\u53ca\u8f6c\u4ea4\u5176\u5b83\u5f00\u673a\u7ba1\u7406\u7a0b\u5e8f\u3002\u8f6c\u4ea4\u8fd9\u4e2a\u529f\u80fd\u53ef\u4ee5\u7528\u6765\u5b9e\u73b0\u4e86\u591a\u91cd\u5f15\u5bfc\uff0c\u53ea\u9700\u8981\u5c06\u53e6\u4e00\u4e2a\u64cd\u4f5c\u7cfb\u7edf\u7684\u5f00\u673a\u7ba1\u7406\u7a0b\u5e8f\u5b89\u88c5\u5728\u5176\u5b83\u5206\u533a\u7684\u542f\u52a8\u6247\u533a\u4e0a\uff0c\u5728\u542f\u52a8\u5f00\u673a\u7ba1\u7406\u7a0b\u5e8f\u65f6\uff0c\u5c31\u53ef\u4ee5\u901a\u8fc7\u9009\u5355\u9009\u62e9\u542f\u52a8\u5f53\u524d\u7684\u64cd\u4f5c\u7cfb\u7edf\u6216\u8005\u8f6c\u4ea4\u7ed9\u5176\u5b83\u5f00\u673a\u7ba1\u7406\u7a0b\u5e8f\u4ece\u800c\u542f\u52a8\u53e6\u4e00\u4e2a\u64cd\u4f5c\u7cfb\u7edf\u3002<\/p>\n<p>\u4e0b\u56fe\u4e2d\uff0c\u7b2c\u4e00\u6247\u533a\u7684\u4e3b\u8981\u5f00\u673a\u8bb0\u5f55\uff08MBR\uff09\u4e2d\u7684\u5f00\u673a\u7ba1\u7406\u7a0b\u5e8f\u63d0\u4f9b\u4e86\u4e24\u4e2a\u9009\u5355\uff1aM1\u3001M2\uff0cM1 \u6307\u5411\u4e86 Windows \u64cd\u4f5c\u7cfb\u7edf\uff0c\u800c M2 \u6307\u5411\u5176\u5b83\u5206\u533a\u7684\u542f\u52a8\u6247\u533a\uff0c\u91cc\u9762\u5305\u542b\u4e86\u53e6\u5916\u4e00\u4e2a\u5f00\u673a\u7ba1\u7406\u7a0b\u5e8f\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e2a\u6307\u5411 Linux \u7684\u9009\u5355\u3002<\/p>\n<div align=\"center\"> <img src=\"pics\/f900f266-a323-42b2-bc43-218fdb8811a8.jpg\" width=\"600\"\/> <\/div>\n<p><\/p>\n<p>\u5b89\u88c5\u591a\u91cd\u5f15\u5bfc\uff0c\u6700\u597d\u5148\u5b89\u88c5 Windows \u518d\u5b89\u88c5 Linux\u3002\u56e0\u4e3a\u5b89\u88c5 Windows \u65f6\u4f1a\u8986\u76d6\u6389\u4e3b\u8981\u5f00\u673a\u8bb0\u5f55\uff08MBR\uff09\uff0c\u800c Linux \u53ef\u4ee5\u9009\u62e9\u5c06\u5f00\u673a\u7ba1\u7406\u7a0b\u5e8f\u5b89\u88c5\u5728\u4e3b\u8981\u5f00\u673a\u8bb0\u5f55\uff08MBR\uff09\u6216\u8005\u5176\u5b83\u5206\u533a\u7684\u542f\u52a8\u6247\u533a\uff0c\u5e76\u4e14\u53ef\u4ee5\u8bbe\u7f6e\u5f00\u673a\u7ba1\u7406\u7a0b\u5e8f\u7684\u9009\u5355\u3002<\/p>\n<h3>2. UEFI<\/h3>\n<p>BIOS \u4e0d\u53ef\u4ee5\u8bfb\u53d6 GPT \u5206\u533a\u8868\uff0c\u800c UEFI \u53ef\u4ee5\u3002<\/p>\n<h1>\u56db\u3001\u6587\u4ef6\u7cfb\u7edf<\/h1>\n<h2>\u5206\u533a\u4e0e\u6587\u4ef6\u7cfb\u7edf<\/h2>\n<p>\u5bf9\u5206\u533a\u8fdb\u884c\u683c\u5f0f\u5316\u662f\u4e3a\u4e86\u5728\u5206\u533a\u4e0a\u5efa\u7acb\u6587\u4ef6\u7cfb\u7edf\u3002\u4e00\u4e2a\u5206\u533a\u901a\u5e38\u53ea\u80fd\u683c\u5f0f\u5316\u4e3a\u4e00\u4e2a\u6587\u4ef6\u7cfb\u7edf\uff0c\u4f46\u662f\u78c1\u76d8\u9635\u5217\u7b49\u6280\u672f\u53ef\u4ee5\u5c06\u4e00\u4e2a\u5206\u533a\u683c\u5f0f\u5316\u4e3a\u591a\u4e2a\u6587\u4ef6\u7cfb\u7edf\u3002<\/p>\n<h2>\u7ec4\u6210<\/h2>\n<p>\u6700\u4e3b\u8981\u7684\u51e0\u4e2a\u7ec4\u6210\u90e8\u5206\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li>inode\uff1a\u4e00\u4e2a\u6587\u4ef6\u5360\u7528\u4e00\u4e2a inode\uff0c\u8bb0\u5f55\u6587\u4ef6\u7684\u5c5e\u6027\uff0c\u540c\u65f6\u8bb0\u5f55\u6b64\u6587\u4ef6\u7684\u5185\u5bb9\u6240\u5728\u7684 block \u7f16\u53f7\uff1b<\/li>\n<li>block\uff1a\u8bb0\u5f55\u6587\u4ef6\u7684\u5185\u5bb9\uff0c\u6587\u4ef6\u592a\u5927\u65f6\uff0c\u4f1a\u5360\u7528\u591a\u4e2a block\u3002<\/li>\n<\/ul>\n<p>\u9664\u6b64\u4e4b\u5916\u8fd8\u5305\u62ec\uff1a<\/p>\n<ul>\n<li>superblock\uff1a\u8bb0\u5f55\u6587\u4ef6\u7cfb\u7edf\u7684\u6574\u4f53\u4fe1\u606f\uff0c\u5305\u62ec inode \u548c block \u7684\u603b\u91cf\u3001\u4f7f\u7528\u91cf\u3001\u5269\u4f59\u91cf\uff0c\u4ee5\u53ca\u6587\u4ef6\u7cfb\u7edf\u7684\u683c\u5f0f\u4e0e\u76f8\u5173\u4fe1\u606f\u7b49\uff1b<\/li>\n<li>block bitmap\uff1a\u8bb0\u5f55 block \u662f\u5426\u88ab\u4f7f\u7528\u7684\u4f4d\u57df\u3002<\/li>\n<\/ul>\n<div align=\"center\"> <img src=\"pics\/BSD_disk.png\" width=\"800\"\/> <\/div>\n<p><\/p>\n<h2>\u6587\u4ef6\u8bfb\u53d6<\/h2>\n<p>\u5bf9\u4e8e Ext2 \u6587\u4ef6\u7cfb\u7edf\uff0c\u5f53\u8981\u8bfb\u53d6\u4e00\u4e2a\u6587\u4ef6\u7684\u5185\u5bb9\u65f6\uff0c\u5148\u5728 inode \u4e2d\u53bb\u67e5\u627e\u6587\u4ef6\u5185\u5bb9\u6240\u5728\u7684\u6240\u6709 block\uff0c\u7136\u540e\u628a\u6240\u6709 block \u7684\u5185\u5bb9\u8bfb\u51fa\u6765\u3002<\/p>\n<div align=\"center\"> <img src=\"pics\/83185315-793a-453a-a927-5e8d92b5c0ef.jpg\"\/> <\/div>\n<p><\/p>\n<p>\u800c\u5bf9\u4e8e FAT \u6587\u4ef6\u7cfb\u7edf\uff0c\u5b83\u6ca1\u6709 inode\uff0c\u6bcf\u4e2a block \u4e2d\u5b58\u50a8\u7740\u4e0b\u4e00\u4e2a block \u7684\u7f16\u53f7\u3002<\/p>\n<div align=\"center\"> <img src=\"pics\/075e1977-7846-4928-96c8-bb5b0268693c.jpg\"\/> <\/div>\n<p><\/p>\n<h2>\u78c1\u76d8\u788e\u7247<\/h2>\n<p>\u6307\u4e00\u4e2a\u6587\u4ef6\u5185\u5bb9\u6240\u5728\u7684 block \u8fc7\u4e8e\u5206\u6563\u3002<\/p>\n<h2>block<\/h2>\n<p>\u5728 Ext2 \u6587\u4ef6\u7cfb\u7edf\u4e2d\u6240\u652f\u6301\u7684 block \u5927\u5c0f\u6709 1K\uff0c2K \u53ca 4K \u4e09\u79cd\uff0c\u4e0d\u540c\u7684\u5927\u5c0f\u9650\u5236\u4e86\u5355\u4e2a\u6587\u4ef6\u548c\u6587\u4ef6\u7cfb\u7edf\u7684\u6700\u5927\u5927\u5c0f\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th align=\"center\">\u5927\u5c0f<\/th>\n<th align=\"center\">1KB<\/th>\n<th align=\"center\">2KB<\/th>\n<th align=\"center\">4KB<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td align=\"center\">\u6700\u5927\u5355\u4e00\u6587\u4ef6<\/td>\n<td align=\"center\">16GB<\/td>\n<td align=\"center\">256GB<\/td>\n<td align=\"center\">2TB<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">\u6700\u5927\u6587\u4ef6\u7cfb\u7edf<\/td>\n<td align=\"center\">2TB<\/td>\n<td align=\"center\">8TB<\/td>\n<td align=\"center\">16TB<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4e00\u4e2a block \u53ea\u80fd\u88ab\u4e00\u4e2a\u6587\u4ef6\u6240\u4f7f\u7528\uff0c\u672a\u4f7f\u7528\u7684\u90e8\u5206\u76f4\u63a5\u6d6a\u8d39\u4e86\u3002\u56e0\u6b64\u5982\u679c\u9700\u8981\u5b58\u50a8\u5927\u91cf\u7684\u5c0f\u6587\u4ef6\uff0c\u90a3\u4e48\u6700\u597d\u9009\u7528\u6bd4\u8f83\u5c0f\u7684 block\u3002<\/p>\n<h2>inode<\/h2>\n<p>inode \u5177\u4f53\u5305\u542b\u4ee5\u4e0b\u4fe1\u606f\uff1a<\/p>\n<ul>\n<li>\u6743\u9650 (read\/write\/excute)\uff1b<\/li>\n<li>\u62e5\u6709\u8005\u4e0e\u7fa4\u7ec4 (owner\/group)\uff1b<\/li>\n<li>\u5bb9\u91cf\uff1b<\/li>\n<li>\u5efa\u7acb\u6216\u72b6\u6001\u6539\u53d8\u7684\u65f6\u95f4 (ctime)\uff1b<\/li>\n<li>\u6700\u8fd1\u4e00\u6b21\u7684\u8bfb\u53d6\u65f6\u95f4 (atime)\uff1b<\/li>\n<li>\u6700\u8fd1\u4fee\u6539\u7684\u65f6\u95f4 (mtime)\uff1b<\/li>\n<li>\u5b9a\u4e49\u6587\u4ef6\u7279\u6027\u7684\u65d7\u6807 (flag)\uff0c\u5982 SetUID&#8230;\uff1b<\/li>\n<li>\u8be5\u6587\u4ef6\u771f\u6b63\u5185\u5bb9\u7684\u6307\u5411 (pointer)\u3002<\/li>\n<\/ul>\n<p>inode \u5177\u6709\u4ee5\u4e0b\u7279\u70b9\uff1a<\/p>\n<ul>\n<li>\u6bcf\u4e2a inode \u5927\u5c0f\u5747\u56fa\u5b9a\u4e3a 128 bytes (\u65b0\u7684 ext4 \u4e0e xfs \u53ef\u8bbe\u5b9a\u5230 256 bytes)\uff1b<\/li>\n<li>\u6bcf\u4e2a\u6587\u4ef6\u90fd\u4ec5\u4f1a\u5360\u7528\u4e00\u4e2a inode\u3002<\/li>\n<\/ul>\n<p>inode \u4e2d\u8bb0\u5f55\u4e86\u6587\u4ef6\u5185\u5bb9\u6240\u5728\u7684 block \u7f16\u53f7\uff0c\u4f46\u662f\u6bcf\u4e2a block \u975e\u5e38\u5c0f\uff0c\u4e00\u4e2a\u5927\u6587\u4ef6\u968f\u4fbf\u90fd\u9700\u8981\u51e0\u5341\u4e07\u7684 block\u3002\u800c\u4e00\u4e2a inode \u5927\u5c0f\u6709\u9650\uff0c\u65e0\u6cd5\u76f4\u63a5\u5f15\u7528\u8fd9\u4e48\u591a block \u7f16\u53f7\u3002\u56e0\u6b64\u5f15\u5165\u4e86\u95f4\u63a5\u3001\u53cc\u95f4\u63a5\u3001\u4e09\u95f4\u63a5\u5f15\u7528\u3002\u95f4\u63a5\u5f15\u7528\u662f\u6307\uff0c\u8ba9 inode \u8bb0\u5f55\u7684\u5f15\u7528 block \u5757\u8bb0\u5f55\u5f15\u7528\u4fe1\u606f\u3002<\/p>\n<div align=\"center\"> <img src=\"pics\/inode_with_signatures.jpg\" width=\"600\"\/> <\/div>\n<p><\/p>\n<h2>\u76ee\u5f55<\/h2>\n<p>\u5efa\u7acb\u4e00\u4e2a\u76ee\u5f55\u65f6\uff0c\u4f1a\u5206\u914d\u4e00\u4e2a inode \u4e0e\u81f3\u5c11\u4e00\u4e2a block\u3002block \u8bb0\u5f55\u7684\u5185\u5bb9\u662f\u76ee\u5f55\u4e0b\u6240\u6709\u6587\u4ef6\u7684 inode \u7f16\u53f7\u4ee5\u53ca\u6587\u4ef6\u540d\u3002<\/p>\n<p>\u53ef\u4ee5\u770b\u51fa\u6587\u4ef6\u7684 inode \u672c\u8eab\u4e0d\u8bb0\u5f55\u6587\u4ef6\u540d\uff0c\u6587\u4ef6\u540d\u8bb0\u5f55\u5728\u76ee\u5f55\u4e2d\uff0c\u56e0\u6b64\u65b0\u589e\u6587\u4ef6\u3001\u5220\u9664\u6587\u4ef6\u3001\u66f4\u6539\u6587\u4ef6\u540d\u8fd9\u4e9b\u64cd\u4f5c\u4e0e\u76ee\u5f55\u7684 w \u6743\u9650\u6709\u5173\u3002<\/p>\n<h2>\u65e5\u5fd7<\/h2>\n<p>\u5982\u679c\u7a81\u7136\u65ad\u7535\uff0c\u90a3\u4e48\u6587\u4ef6\u7cfb\u7edf\u4f1a\u53d1\u751f\u9519\u8bef\uff0c\u4f8b\u5982\u65ad\u7535\u524d\u53ea\u4fee\u6539\u4e86 block bitmap\uff0c\u800c\u8fd8\u6ca1\u6709\u5c06\u6570\u636e\u771f\u6b63\u5199\u5165 block \u4e2d\u3002<\/p>\n<p>ext3\/ext4 \u6587\u4ef6\u7cfb\u7edf\u5f15\u5165\u4e86\u65e5\u5fd7\u529f\u80fd\uff0c\u53ef\u4ee5\u5229\u7528\u65e5\u5fd7\u6765\u4fee\u590d\u6587\u4ef6\u7cfb\u7edf\u3002<\/p>\n<h2>\u6302\u8f7d<\/h2>\n<p>\u6302\u8f7d\u5229\u7528\u76ee\u5f55\u4f5c\u4e3a\u6587\u4ef6\u7cfb\u7edf\u7684\u8fdb\u5165\u70b9\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u8fdb\u5165\u76ee\u5f55\u4e4b\u540e\u5c31\u53ef\u4ee5\u8bfb\u53d6\u6587\u4ef6\u7cfb\u7edf\u7684\u6570\u636e\u3002<\/p>\n<h2>\u76ee\u5f55\u914d\u7f6e<\/h2>\n<p>\u4e3a\u4e86\u4f7f\u4e0d\u540c Linux \u53d1\u884c\u7248\u672c\u7684\u76ee\u5f55\u7ed3\u6784\u4fdd\u6301\u4e00\u81f4\u6027\uff0cFilesystem Hierarchy Standard (FHS) \u89c4\u5b9a\u4e86 Linux \u7684\u76ee\u5f55\u7ed3\u6784\u3002\u6700\u57fa\u7840\u7684\u4e09\u4e2a\u76ee\u5f55\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li>\/ (root, \u6839\u76ee\u5f55)<\/li>\n<li>\/usr (unix software resource)\uff1a\u6240\u6709\u7cfb\u7edf\u9ed8\u8ba4\u8f6f\u4ef6\u90fd\u4f1a\u5b89\u88c5\u5230\u8fd9\u4e2a\u76ee\u5f55\uff1b<\/li>\n<li>\/var (variable)\uff1a\u5b58\u653e\u7cfb\u7edf\u6216\u7a0b\u5e8f\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u7684\u6570\u636e\u6587\u4ef6\u3002<\/li>\n<\/ul>\n<div align=\"center\"> <img src=\"pics\/linux-filesystem.png\" width=\"\"\/> <\/div>\n<p><\/p>\n<h1>\u4e94\u3001\u6587\u4ef6<\/h1>\n<h2>\u6587\u4ef6\u5c5e\u6027<\/h2>\n<p>\u7528\u6237\u5206\u4e3a\u4e09\u79cd\uff1a\u6587\u4ef6\u62e5\u6709\u8005\u3001\u7fa4\u7ec4\u4ee5\u53ca\u5176\u5b83\u4eba\uff0c\u5bf9\u4e0d\u540c\u7684\u7528\u6237\u6709\u4e0d\u540c\u7684\u6587\u4ef6\u6743\u9650\u3002<\/p>\n<p>\u4f7f\u7528 ls \u67e5\u770b\u4e00\u4e2a\u6587\u4ef6\u65f6\uff0c\u4f1a\u663e\u793a\u4e00\u4e2a\u6587\u4ef6\u7684\u4fe1\u606f\uff0c\u4f8b\u5982 <code>drwxr-xr-x. 3 root root 17 May 6 00:14 .config<\/code>\uff0c\u5bf9\u8fd9\u4e2a\u4fe1\u606f\u7684\u89e3\u91ca\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li>drwxr-xr-x\uff1a\u6587\u4ef6\u7c7b\u578b\u4ee5\u53ca\u6743\u9650\uff0c\u7b2c 1 \u4f4d\u4e3a\u6587\u4ef6\u7c7b\u578b\u5b57\u6bb5\uff0c\u540e 9 \u4f4d\u4e3a\u6587\u4ef6\u6743\u9650\u5b57\u6bb5<\/li>\n<li>3\uff1a\u94fe\u63a5\u6570<\/li>\n<li>root\uff1a\u6587\u4ef6\u62e5\u6709\u8005<\/li>\n<li>root\uff1a\u6240\u5c5e\u7fa4\u7ec4<\/li>\n<li>17\uff1a\u6587\u4ef6\u5927\u5c0f<\/li>\n<li>May 6 00:14\uff1a\u6587\u4ef6\u6700\u540e\u88ab\u4fee\u6539\u7684\u65f6\u95f4<\/li>\n<li>.config\uff1a\u6587\u4ef6\u540d<\/li>\n<\/ul>\n<p>\u5e38\u89c1\u7684\u6587\u4ef6\u7c7b\u578b\u53ca\u5176\u542b\u4e49\u6709\uff1a<\/p>\n<ul>\n<li>d\uff1a\u76ee\u5f55<\/li>\n<li>-\uff1a\u6587\u4ef6<\/li>\n<li>l\uff1a\u94fe\u63a5\u6587\u4ef6<\/li>\n<\/ul>\n<p>9 \u4f4d\u7684\u6587\u4ef6\u6743\u9650\u5b57\u6bb5\u4e2d\uff0c\u6bcf 3 \u4e2a\u4e3a\u4e00\u7ec4\uff0c\u5171 3 \u7ec4\uff0c\u6bcf\u4e00\u7ec4\u5206\u522b\u4ee3\u8868\u5bf9\u6587\u4ef6\u62e5\u6709\u8005\u3001\u6240\u5c5e\u7fa4\u7ec4\u4ee5\u53ca\u5176\u5b83\u4eba\u7684\u6587\u4ef6\u6743\u9650\u3002\u4e00\u7ec4\u6743\u9650\u4e2d\u7684 3 \u4f4d\u5206\u522b\u4e3a r\u3001w\u3001x \u6743\u9650\uff0c\u8868\u793a\u53ef\u8bfb\u3001\u53ef\u5199\u3001\u53ef\u6267\u884c\u3002<\/p>\n<p>\u6587\u4ef6\u65f6\u95f4\u6709\u4ee5\u4e0b\u4e09\u79cd\uff1a<\/p>\n<ul>\n<li>modification time (mtime)\uff1a\u6587\u4ef6\u7684\u5185\u5bb9\u66f4\u65b0\u5c31\u4f1a\u66f4\u65b0\uff1b<\/li>\n<li>status time (ctime)\uff1a\u6587\u4ef6\u7684\u72b6\u6001\uff08\u6743\u9650\u3001\u5c5e\u6027\uff09\u66f4\u65b0\u5c31\u4f1a\u66f4\u65b0\uff1b<\/li>\n<li>access time (atime)\uff1a\u8bfb\u53d6\u6587\u4ef6\u65f6\u5c31\u4f1a\u66f4\u65b0\u3002<\/li>\n<\/ul>\n<h2>\u6587\u4ef6\u4e0e\u76ee\u5f55\u7684\u57fa\u672c\u64cd\u4f5c<\/h2>\n<h3>1. ls<\/h3>\n<p>\u5217\u51fa\u6587\u4ef6\u6216\u8005\u76ee\u5f55\u7684\u4fe1\u606f\uff0c\u76ee\u5f55\u7684\u4fe1\u606f\u5c31\u662f\u5176\u4e2d\u5305\u542b\u7684\u6587\u4ef6\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n# ls [-aAdfFhilnrRSt] file|dir\n-a \uff1a\u5217\u51fa\u5168\u90e8\u7684\u6587\u4ef6\n-d \uff1a\u4ec5\u5217\u51fa\u76ee\u5f55\u672c\u8eab\n-l \uff1a\u4ee5\u957f\u6570\u636e\u4e32\u884c\u5217\u51fa\uff0c\u5305\u542b\u6587\u4ef6\u7684\u5c5e\u6027\u4e0e\u6743\u9650\u7b49\u7b49\u6570\u636e\n<\/pre>\n<h3>2. cd<\/h3>\n<p>\u66f4\u6362\u5f53\u524d\u76ee\u5f55\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ncd [\u76f8\u5bf9\u8def\u5f84\u6216\u7edd\u5bf9\u8def\u5f84]\n<\/pre>\n<h3>3. mkdir<\/h3>\n<p>\u521b\u5efa\u76ee\u5f55\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n# mkdir [-mp] \u76ee\u5f55\u540d\u79f0\n-m \uff1a\u914d\u7f6e\u76ee\u5f55\u6743\u9650\n-p \uff1a\u9012\u5f52\u521b\u5efa\u76ee\u5f55\n<\/pre>\n<h3>4. rmdir<\/h3>\n<p>\u5220\u9664\u76ee\u5f55\uff0c\u76ee\u5f55\u5fc5\u987b\u4e3a\u7a7a\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\nrmdir [-p] \u76ee\u5f55\u540d\u79f0\n-p \uff1a\u9012\u5f52\u5220\u9664\u76ee\u5f55\n<\/pre>\n<h3>5. touch<\/h3>\n<p>\u66f4\u65b0\u6587\u4ef6\u65f6\u95f4\u6216\u8005\u5efa\u7acb\u65b0\u6587\u4ef6\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n# touch [-acdmt] filename\n-a \uff1a \u66f4\u65b0 atime\n-c \uff1a \u66f4\u65b0 ctime\uff0c\u82e5\u8be5\u6587\u4ef6\u4e0d\u5b58\u5728\u5219\u4e0d\u5efa\u7acb\u65b0\u6587\u4ef6\n-m \uff1a \u66f4\u65b0 mtime\n-d \uff1a \u540e\u9762\u53ef\u4ee5\u63a5\u66f4\u65b0\u65e5\u671f\u800c\u4e0d\u4f7f\u7528\u5f53\u524d\u65e5\u671f\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 --date=&amp;quot;\u65e5\u671f\u6216\u65f6\u95f4&amp;quot;\n-t \uff1a \u540e\u9762\u53ef\u4ee5\u63a5\u66f4\u65b0\u65f6\u95f4\u800c\u4e0d\u4f7f\u7528\u5f53\u524d\u65f6\u95f4\uff0c\u683c\u5f0f\u4e3a[YYYYMMDDhhmm]\n<\/pre>\n<h3>6. cp<\/h3>\n<p>\u590d\u5236\u6587\u4ef6\u3002<\/p>\n<p>\u5982\u679c\u6e90\u6587\u4ef6\u6709\u4e24\u4e2a\u4ee5\u4e0a\uff0c\u5219\u76ee\u7684\u6587\u4ef6\u4e00\u5b9a\u8981\u662f\u76ee\u5f55\u624d\u884c\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\ncp [-adfilprsu] source destination\n-a \uff1a\u76f8\u5f53\u4e8e -dr --preserve=all \u7684\u610f\u601d\uff0c\u81f3\u4e8e dr \u8bf7\u53c2\u8003\u4e0b\u5217\u8bf4\u660e\n-d \uff1a\u82e5\u6765\u6e90\u6587\u4ef6\u4e3a\u94fe\u63a5\u6587\u4ef6\uff0c\u5219\u590d\u5236\u94fe\u63a5\u6587\u4ef6\u5c5e\u6027\u800c\u975e\u6587\u4ef6\u672c\u8eab\n-i \uff1a\u82e5\u76ee\u6807\u6587\u4ef6\u5df2\u7ecf\u5b58\u5728\u65f6\uff0c\u5728\u8986\u76d6\u524d\u4f1a\u5148\u8be2\u95ee\n-p \uff1a\u8fde\u540c\u6587\u4ef6\u7684\u5c5e\u6027\u4e00\u8d77\u590d\u5236\u8fc7\u53bb\n-r \uff1a\u9012\u5f52\u6301\u7eed\u590d\u5236\n-u \uff1adestination \u6bd4 source \u65e7\u624d\u66f4\u65b0 destination\uff0c\u6216 destination \u4e0d\u5b58\u5728\u7684\u60c5\u51b5\u4e0b\u624d\u590d\u5236\n--preserve=all \uff1a\u9664\u4e86 -p \u7684\u6743\u9650\u76f8\u5173\u53c2\u6570\u5916\uff0c\u8fd8\u52a0\u5165 SELinux \u7684\u5c5e\u6027, links, xattr \u7b49\u4e5f\u590d\u5236\u4e86\n<\/pre>\n<h3>7. rm<\/h3>\n<p>\u5220\u9664\u6587\u4ef6\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n# rm [-fir] \u6587\u4ef6\u6216\u76ee\u5f55\n-r \uff1a\u9012\u5f52\u5220\u9664\n<\/pre>\n<h3>8. mv<\/h3>\n<p>\u79fb\u52a8\u6587\u4ef6\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n# mv [-fiu] source destination\n# mv [options] source1 source2 source3 .... directory\n-f \uff1a force \u5f3a\u5236\u7684\u610f\u601d\uff0c\u5982\u679c\u76ee\u6807\u6587\u4ef6\u5df2\u7ecf\u5b58\u5728\uff0c\u4e0d\u4f1a\u8be2\u95ee\u800c\u76f4\u63a5\u8986\u76d6\n<\/pre>\n<h2>\u4fee\u6539\u6743\u9650<\/h2>\n<p>\u53ef\u4ee5\u5c06\u4e00\u7ec4\u6743\u9650\u7528\u6570\u5b57\u6765\u8868\u793a\uff0c\u6b64\u65f6\u4e00\u7ec4\u6743\u9650\u7684 3 \u4e2a\u4f4d\u5f53\u505a\u4e8c\u8fdb\u5236\u6570\u5b57\u7684\u4f4d\uff0c\u4ece\u5de6\u5230\u53f3\u6bcf\u4e2a\u4f4d\u7684\u6743\u503c\u4e3a 4\u30012\u30011\uff0c\u5373\u6bcf\u4e2a\u6743\u9650\u5bf9\u5e94\u7684\u6570\u5b57\u6743\u503c\u4e3a r : 4\u3001w : 2\u3001x : 1\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n# chmod [-R] xyz dirname\/filename\n<\/pre>\n<p>\u793a\u4f8b\uff1a\u5c06 .bashrc \u6587\u4ef6\u7684\u6743\u9650\u4fee\u6539\u4e3a -rwxr-xr&#8211;\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n# chmod 754 .bashrc\n<\/pre>\n<p>\u4e5f\u53ef\u4ee5\u4f7f\u7528\u7b26\u53f7\u6765\u8bbe\u5b9a\u6743\u9650\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n# chmod [ugoa]  [+-=] [rwx] dirname\/filename\n- u\uff1a\u62e5\u6709\u8005\n- g\uff1a\u6240\u5c5e\u7fa4\u7ec4\n- o\uff1a\u5176\u4ed6\u4eba\n- a\uff1a\u6240\u6709\u4eba\n- +\uff1a\u6dfb\u52a0\u6743\u9650\n- -\uff1a\u79fb\u9664\u6743\u9650\n- =\uff1a\u8bbe\u5b9a\u6743\u9650\n<\/pre>\n<p>\u793a\u4f8b\uff1a\u4e3a .bashrc \u6587\u4ef6\u7684\u6240\u6709\u7528\u6237\u6dfb\u52a0\u5199\u6743\u9650\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n# chmod a+w .bashrc\n<\/pre>\n<h2>\u6587\u4ef6\u9ed8\u8ba4\u6743\u9650<\/h2>\n<ul>\n<li>\u6587\u4ef6\u9ed8\u8ba4\u6743\u9650\uff1a\u6587\u4ef6\u9ed8\u8ba4\u6ca1\u6709\u53ef\u6267\u884c\u6743\u9650\uff0c\u56e0\u6b64\u4e3a 666\uff0c\u4e5f\u5c31\u662f -rw-rw-rw- \u3002<\/li>\n<li>\u76ee\u5f55\u9ed8\u8ba4\u6743\u9650\uff1a\u76ee\u5f55\u5fc5\u987b\u8981\u80fd\u591f\u8fdb\u5165\uff0c\u4e5f\u5c31\u662f\u5fc5\u987b\u62e5\u6709\u53ef\u6267\u884c\u6743\u9650\uff0c\u56e0\u6b64\u4e3a 777 \uff0c\u4e5f\u5c31\u662f drwxrwxrwx\u3002<\/li>\n<\/ul>\n<p>\u53ef\u4ee5\u901a\u8fc7 umask \u8bbe\u7f6e\u6216\u8005\u67e5\u770b\u6587\u4ef6\u7684\u9ed8\u8ba4\u6743\u9650\uff0c\u901a\u5e38\u4ee5\u63a9\u7801\u7684\u5f62\u5f0f\u6765\u8868\u793a\uff0c\u4f8b\u5982 002 \u8868\u793a\u5176\u5b83\u7528\u6237\u7684\u6743\u9650\u53bb\u9664\u4e86\u4e00\u4e2a 2 \u7684\u6743\u9650\uff0c\u4e5f\u5c31\u662f\u5199\u6743\u9650\uff0c\u56e0\u6b64\u5efa\u7acb\u65b0\u6587\u4ef6\u65f6\u9ed8\u8ba4\u7684\u6743\u9650\u4e3a -rw-rw-r&#8211;\u3002<\/p>\n<h2>\u76ee\u5f55\u7684\u6743\u9650<\/h2>\n<p>\u6587\u4ef6\u540d\u4e0d\u662f\u5b58\u50a8\u5728\u4e00\u4e2a\u6587\u4ef6\u7684\u5185\u5bb9\u4e2d\uff0c\u800c\u662f\u5b58\u50a8\u5728\u4e00\u4e2a\u6587\u4ef6\u6240\u5728\u7684\u76ee\u5f55\u4e2d\u3002\u56e0\u6b64\uff0c\u62e5\u6709\u6587\u4ef6\u7684 w \u6743\u9650\u5e76\u4e0d\u80fd\u5bf9\u6587\u4ef6\u540d\u8fdb\u884c\u4fee\u6539\u3002<\/p>\n<p>\u76ee\u5f55\u5b58\u50a8\u6587\u4ef6\u5217\u8868\uff0c\u4e00\u4e2a\u76ee\u5f55\u7684\u6743\u9650\u4e5f\u5c31\u662f\u5bf9\u5176\u6587\u4ef6\u5217\u8868\u7684\u6743\u9650\u3002\u56e0\u6b64\uff0c\u76ee\u5f55\u7684 r \u6743\u9650\u8868\u793a\u53ef\u4ee5\u8bfb\u53d6\u6587\u4ef6\u5217\u8868\uff1bw \u6743\u9650\u8868\u793a\u53ef\u4ee5\u4fee\u6539\u6587\u4ef6\u5217\u8868\uff0c\u5177\u4f53\u6765\u8bf4\uff0c\u5c31\u662f\u6dfb\u52a0\u5220\u9664\u6587\u4ef6\uff0c\u5bf9\u6587\u4ef6\u540d\u8fdb\u884c\u4fee\u6539\uff1bx \u6743\u9650\u53ef\u4ee5\u8ba9\u8be5\u76ee\u5f55\u6210\u4e3a\u5de5\u4f5c\u76ee\u5f55\uff0cx \u6743\u9650\u662f r \u548c w \u6743\u9650\u7684\u57fa\u7840\uff0c\u5982\u679c\u4e0d\u80fd\u4f7f\u4e00\u4e2a\u76ee\u5f55\u6210\u4e3a\u5de5\u4f5c\u76ee\u5f55\uff0c\u4e5f\u5c31\u6ca1\u529e\u6cd5\u8bfb\u53d6\u6587\u4ef6\u5217\u8868\u4ee5\u53ca\u5bf9\u6587\u4ef6\u5217\u8868\u8fdb\u884c\u4fee\u6539\u4e86\u3002<\/p>\n<h2>\u94fe\u63a5<\/h2>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n# ln [-sf] source_filename dist_filename\n-s \uff1a\u9ed8\u8ba4\u662f hard link\uff0c\u52a0 -s \u4e3a symbolic link\n-f \uff1a\u5982\u679c\u76ee\u6807\u6587\u4ef6\u5b58\u5728\u65f6\uff0c\u5148\u5220\u9664\u76ee\u6807\u6587\u4ef6\n<\/pre>\n<div align=\"center\"> <img src=\"pics\/b8081c84-62c4-4019-b3ee-4bd0e443d647.jpg\" width=\"400px\"> <\/div>\n<p><\/p>\n<h3>1. \u5b9e\u4f53\u94fe\u63a5<\/h3>\n<p>\u5728\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u6761\u76ee\uff0c\u8bb0\u5f55\u7740\u6587\u4ef6\u540d\u4e0e inode \u7f16\u53f7\uff0c\u8fd9\u4e2a inode \u5c31\u662f\u6e90\u6587\u4ef6\u7684 inode\u3002<\/p>\n<p>\u5220\u9664\u4efb\u610f\u4e00\u4e2a\u6761\u76ee\uff0c\u6587\u4ef6\u8fd8\u662f\u5b58\u5728\uff0c\u53ea\u8981\u5f15\u7528\u6570\u91cf\u4e0d\u4e3a 0\u3002<\/p>\n<p>\u6709\u4ee5\u4e0b\u9650\u5236\uff1a\u4e0d\u80fd\u8de8\u8d8a\u6587\u4ef6\u7cfb\u7edf\u3001\u4e0d\u80fd\u5bf9\u76ee\u5f55\u8fdb\u884c\u94fe\u63a5\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n# ln \/etc\/crontab .\n# ll -i \/etc\/crontab crontab\n34474855 -rw-r--r--. 2 root root 451 Jun 10 2014 crontab\n34474855 -rw-r--r--. 2 root root 451 Jun 10 2014 \/etc\/crontab\n<\/pre>\n<h3>2. \u7b26\u53f7\u94fe\u63a5<\/h3>\n<p>\u7b26\u53f7\u94fe\u63a5\u6587\u4ef6\u4fdd\u5b58\u7740\u6e90\u6587\u4ef6\u6240\u5728\u7684\u7edd\u5bf9\u8def\u5f84\uff0c\u5728\u8bfb\u53d6\u65f6\u4f1a\u5b9a\u4f4d\u5230\u6e90\u6587\u4ef6\u4e0a\uff0c\u53ef\u4ee5\u7406\u89e3\u4e3a Windows \u7684\u5feb\u6377\u65b9\u5f0f\u3002<\/p>\n<p>\u5f53\u6e90\u6587\u4ef6\u88ab\u5220\u9664\u4e86\uff0c\u94fe\u63a5\u6587\u4ef6\u5c31\u6253\u4e0d\u5f00\u4e86\u3002<\/p>\n<p>\u53ef\u4ee5\u4e3a\u76ee\u5f55\u5efa\u7acb\u94fe\u63a5\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n# ll -i \/etc\/crontab \/root\/crontab2\n34474855 -rw-r--r--. 2 root root 451 Jun 10 2014 \/etc\/crontab\n53745909 lrwxrwxrwx. 1 root root 12 Jun 23 22:31 \/root\/crontab2 -&amp;gt; \/etc\/crontab\n<\/pre>\n<h2>\u83b7\u53d6\u6587\u4ef6\u5185\u5bb9<\/h2>\n<h3>1. cat<\/h3>\n<p>\u53d6\u5f97\u6587\u4ef6\u5185\u5bb9\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n# cat [-AbEnTv] filename\n-n \uff1a\u6253\u5370\u51fa\u884c\u53f7\uff0c\u8fde\u540c\u7a7a\u767d\u884c\u4e5f\u4f1a\u6709\u884c\u53f7\uff0c-b \u4e0d\u4f1a\n<\/pre>\n<h3>2. tac<\/h3>\n<p>\u662f cat \u7684\u53cd\u5411\u64cd\u4f5c\uff0c\u4ece\u6700\u540e\u4e00\u884c\u5f00\u59cb\u6253\u5370\u3002<\/p>\n<h3>3. more<\/h3>\n<p>\u548c cat \u4e0d\u540c\u7684\u662f\u5b83\u53ef\u4ee5\u4e00\u9875\u4e00\u9875\u67e5\u770b\u6587\u4ef6\u5185\u5bb9\uff0c\u6bd4\u8f83\u9002\u5408\u5927\u6587\u4ef6\u7684\u67e5\u770b\u3002<\/p>\n<h3>4. less<\/h3>\n<p>\u548c more \u7c7b\u4f3c\uff0c\u4f46\u662f\u591a\u4e86\u4e00\u4e2a\u5411\u524d\u7ffb\u9875\u7684\u529f\u80fd\u3002<\/p>\n<h3>5. head<\/h3>\n<p>\u53d6\u5f97\u6587\u4ef6\u524d\u51e0\u884c\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n# head [-n number] filename\n-n \uff1a\u540e\u9762\u63a5\u6570\u5b57\uff0c\u4ee3\u8868\u663e\u793a\u51e0\u884c\u7684\u610f\u601d\n<\/pre>\n<h3>6. tail<\/h3>\n<p>\u662f head \u7684\u53cd\u5411\u64cd\u4f5c\uff0c\u53ea\u662f\u53d6\u5f97\u662f\u540e\u51e0\u884c\u3002<\/p>\n<h3>7. od<\/h3>\n<p>\u4ee5\u5b57\u7b26\u6216\u8005\u5341\u516d\u8fdb\u5236\u7684\u5f62\u5f0f\u663e\u793a\u4e8c\u8fdb\u5236\u6587\u4ef6\u3002<\/p>\n<h2>\u6307\u4ee4\u4e0e\u6587\u4ef6\u641c\u7d22<\/h2>\n<h3>1. which<\/h3>\n<p>\u6307\u4ee4\u641c\u7d22\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n# which [-a] command\n-a \uff1a\u5c06\u6240\u6709\u6307\u4ee4\u5217\u51fa\uff0c\u800c\u4e0d\u662f\u53ea\u5217\u7b2c\u4e00\u4e2a\n<\/pre>\n<h3>2. whereis<\/h3>\n<p>\u6587\u4ef6\u641c\u7d22\u3002\u901f\u5ea6\u6bd4\u8f83\u5feb\uff0c\u56e0\u4e3a\u5b83\u53ea\u641c\u7d22\u51e0\u4e2a\u7279\u5b9a\u7684\u76ee\u5f55\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n# whereis [-bmsu] dirname\/filename\n<\/pre>\n<h3>3. locate<\/h3>\n<p>\u6587\u4ef6\u641c\u7d22\u3002\u53ef\u4ee5\u7528\u5173\u952e\u5b57\u6216\u8005\u6b63\u5219\u8868\u8fbe\u5f0f\u8fdb\u884c\u641c\u7d22\u3002<\/p>\n<p>locate \u4f7f\u7528 \/var\/lib\/mlocate\/ \u8fd9\u4e2a\u6570\u636e\u5e93\u6765\u8fdb\u884c\u641c\u7d22\uff0c\u5b83\u5b58\u50a8\u5728\u5185\u5b58\u4e2d\uff0c\u5e76\u4e14\u6bcf\u5929\u66f4\u65b0\u4e00\u6b21\uff0c\u6240\u4ee5\u65e0\u6cd5\u7528 locate \u641c\u7d22\u65b0\u5efa\u7684\u6587\u4ef6\u3002\u53ef\u4ee5\u4f7f\u7528 updatedb \u6765\u7acb\u5373\u66f4\u65b0\u6570\u636e\u5e93\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n# locate [-ir] keyword\n-r\uff1a\u6b63\u5219\u8868\u8fbe\u5f0f\n<\/pre>\n<h3>4. find<\/h3>\n<p>\u6587\u4ef6\u641c\u7d22\u3002\u53ef\u4ee5\u4f7f\u7528\u6587\u4ef6\u7684\u5c5e\u6027\u548c\u6743\u9650\u8fdb\u884c\u641c\u7d22\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n# find [basedir] [option]\nexample: find . -name &amp;quot;shadow*&amp;quot;\n<\/pre>\n<p><strong>\u2460 \u4e0e\u65f6\u95f4\u6709\u5173\u7684\u9009\u9879<\/strong><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n-mtime  n \uff1a\u5217\u51fa\u5728 n \u5929\u524d\u7684\u90a3\u4e00\u5929\u4fee\u6539\u8fc7\u5185\u5bb9\u7684\u6587\u4ef6\n-mtime +n \uff1a\u5217\u51fa\u5728 n \u5929\u4e4b\u524d (\u4e0d\u542b n \u5929\u672c\u8eab) \u4fee\u6539\u8fc7\u5185\u5bb9\u7684\u6587\u4ef6\n-mtime -n \uff1a\u5217\u51fa\u5728 n \u5929\u4e4b\u5185 (\u542b n \u5929\u672c\u8eab) \u4fee\u6539\u8fc7\u5185\u5bb9\u7684\u6587\u4ef6\n-newer file \uff1a \u5217\u51fa\u6bd4 file \u66f4\u65b0\u7684\u6587\u4ef6\n<\/pre>\n<p>+4\u30014 \u548c -4 \u7684\u6307\u793a\u7684\u65f6\u95f4\u8303\u56f4\u5982\u4e0b\uff1a<\/p>\n<div align=\"center\"> <img src=\"pics\/658fc5e7-79c0-4247-9445-d69bf194c539.png\" width=\"\"\/> <\/div>\n<p><\/p>\n<p><strong>\u2461 \u4e0e\u6587\u4ef6\u62e5\u6709\u8005\u548c\u6240\u5c5e\u7fa4\u7ec4\u6709\u5173\u7684\u9009\u9879<\/strong><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n-uid n\n-gid n\n-user name\n-group name\n-nouser \uff1a\u641c\u7d22\u62e5\u6709\u8005\u4e0d\u5b58\u5728 \/etc\/passwd \u7684\u6587\u4ef6\n-nogroup\uff1a\u641c\u7d22\u6240\u5c5e\u7fa4\u7ec4\u4e0d\u5b58\u5728\u4e8e \/etc\/group \u7684\u6587\u4ef6\n<\/pre>\n<p><strong>\u2462 \u4e0e\u6587\u4ef6\u6743\u9650\u548c\u540d\u79f0\u6709\u5173\u7684\u9009\u9879<\/strong><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n-name filename\n-size [+-]SIZE\uff1a\u641c\u5bfb\u6bd4 SIZE \u8fd8\u8981\u5927 (+) \u6216\u5c0f (-) \u7684\u6587\u4ef6\u3002\u8fd9\u4e2a SIZE \u7684\u89c4\u683c\u6709\uff1ac: \u4ee3\u8868 byte\uff0ck: \u4ee3\u8868 1024bytes\u3002\u6240\u4ee5\uff0c\u8981\u627e\u6bd4 50KB \u8fd8\u8981\u5927\u7684\u6587\u4ef6\uff0c\u5c31\u662f -size +50k\n-type TYPE\n-perm mode  \uff1a\u641c\u7d22\u6743\u9650\u7b49\u4e8e mode \u7684\u6587\u4ef6\n-perm -mode \uff1a\u641c\u7d22\u6743\u9650\u5305\u542b mode \u7684\u6587\u4ef6\n-perm \/mode \uff1a\u641c\u7d22\u6743\u9650\u5305\u542b\u4efb\u4e00 mode \u7684\u6587\u4ef6\n<\/pre>\n<h1>\u516d\u3001\u538b\u7f29\u4e0e\u6253\u5305<\/h1>\n<h2>\u538b\u7f29\u6587\u4ef6\u540d<\/h2>\n<p>Linux \u5e95\u4e0b\u6709\u5f88\u591a\u538b\u7f29\u6587\u4ef6\u540d\uff0c\u5e38\u89c1\u7684\u5982\u4e0b\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u6269\u5c55\u540d<\/th>\n<th>\u538b\u7f29\u7a0b\u5e8f<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>&#42;.Z<\/td>\n<td>compress<\/td>\n<\/tr>\n<tr>\n<td>&#42;.zip<\/td>\n<td>zip<\/td>\n<\/tr>\n<tr>\n<td>&#42;.gz<\/td>\n<td>gzip<\/td>\n<\/tr>\n<tr>\n<td>&#42;.bz2<\/td>\n<td>bzip2<\/td>\n<\/tr>\n<tr>\n<td>&#42;.xz<\/td>\n<td>xz<\/td>\n<\/tr>\n<tr>\n<td>&#42;.tar<\/td>\n<td>tar \u7a0b\u5e8f\u6253\u5305\u7684\u6570\u636e\uff0c\u6ca1\u6709\u7ecf\u8fc7\u538b\u7f29<\/td>\n<\/tr>\n<tr>\n<td>&#42;.tar.gz<\/td>\n<td>tar \u7a0b\u5e8f\u6253\u5305\u7684\u6587\u4ef6\uff0c\u7ecf\u8fc7 gzip \u7684\u538b\u7f29<\/td>\n<\/tr>\n<tr>\n<td>&#42;.tar.bz2<\/td>\n<td>tar \u7a0b\u5e8f\u6253\u5305\u7684\u6587\u4ef6\uff0c\u7ecf\u8fc7 bzip2 \u7684\u538b\u7f29<\/td>\n<\/tr>\n<tr>\n<td>&#42;.tar.xz<\/td>\n<td>tar \u7a0b\u5e8f\u6253\u5305\u7684\u6587\u4ef6\uff0c\u7ecf\u8fc7 xz \u7684\u538b\u7f29<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u538b\u7f29\u6307\u4ee4<\/h2>\n<h3>1. gzip<\/h3>\n<p>gzip \u662f Linux \u4f7f\u7528\u6700\u5e7f\u7684\u538b\u7f29\u6307\u4ee4\uff0c\u53ef\u4ee5\u89e3\u5f00 compress\u3001zip \u4e0e gzip \u6240\u538b\u7f29\u7684\u6587\u4ef6\u3002<\/p>\n<p>\u7ecf\u8fc7 gzip \u538b\u7f29\u8fc7\uff0c\u6e90\u6587\u4ef6\u5c31\u4e0d\u5b58\u5728\u4e86\u3002<\/p>\n<p>\u6709 9 \u4e2a\u4e0d\u540c\u7684\u538b\u7f29\u7b49\u7ea7\u53ef\u4ee5\u4f7f\u7528\u3002<\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528 zcat\u3001zmore\u3001zless \u6765\u8bfb\u53d6\u538b\u7f29\u6587\u4ef6\u7684\u5185\u5bb9\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n$ gzip [-cdtv#] filename\n-c \uff1a\u5c06\u538b\u7f29\u7684\u6570\u636e\u8f93\u51fa\u5230\u5c4f\u5e55\u4e0a\n-d \uff1a\u89e3\u538b\u7f29\n-t \uff1a\u68c0\u9a8c\u538b\u7f29\u6587\u4ef6\u662f\u5426\u51fa\u9519\n-v \uff1a\u663e\u793a\u538b\u7f29\u6bd4\u7b49\u4fe1\u606f\n-# \uff1a # \u4e3a\u6570\u5b57\u7684\u610f\u601d\uff0c\u4ee3\u8868\u538b\u7f29\u7b49\u7ea7\uff0c\u6570\u5b57\u8d8a\u5927\u538b\u7f29\u6bd4\u8d8a\u9ad8\uff0c\u9ed8\u8ba4\u4e3a 6\n<\/pre>\n<h3>2. bzip2<\/h3>\n<p>\u63d0\u4f9b\u6bd4 gzip \u66f4\u9ad8\u7684\u538b\u7f29\u6bd4\u3002<\/p>\n<p>\u67e5\u770b\u547d\u4ee4\uff1abzcat\u3001bzmore\u3001bzless\u3001bzgrep\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n$ bzip2 [-cdkzv#] filename\n-k \uff1a\u4fdd\u7559\u6e90\u6587\u4ef6\n<\/pre>\n<h3>3. xz<\/h3>\n<p>\u63d0\u4f9b\u6bd4 bzip2 \u66f4\u4f73\u7684\u538b\u7f29\u6bd4\u3002<\/p>\n<p>\u53ef\u4ee5\u770b\u5230\uff0cgzip\u3001bzip2\u3001xz \u7684\u538b\u7f29\u6bd4\u4e0d\u65ad\u4f18\u5316\u3002\u4e0d\u8fc7\u8981\u6ce8\u610f\u7684\u662f\uff0c\u538b\u7f29\u6bd4\u8d8a\u9ad8\uff0c\u538b\u7f29\u7684\u65f6\u95f4\u4e5f\u8d8a\u957f\u3002<\/p>\n<p>\u67e5\u770b\u547d\u4ee4\uff1axzcat\u3001xzmore\u3001xzless\u3001xzgrep\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n$ xz [-dtlkc#] filename\n<\/pre>\n<h2>\u6253\u5305<\/h2>\n<p>\u538b\u7f29\u6307\u4ee4\u53ea\u80fd\u5bf9\u4e00\u4e2a\u6587\u4ef6\u8fdb\u884c\u538b\u7f29\uff0c\u800c\u6253\u5305\u80fd\u591f\u5c06\u591a\u4e2a\u6587\u4ef6\u6253\u5305\u6210\u4e00\u4e2a\u5927\u6587\u4ef6\u3002tar \u4e0d\u4ec5\u53ef\u4ee5\u7528\u4e8e\u6253\u5305\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 gip\u3001bzip2\u3001xz \u5c06\u6253\u5305\u6587\u4ef6\u8fdb\u884c\u538b\u7f29\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n<span class=\"katex math inline\">tar [-z|-j|-J] [cv] [-f \u65b0\u5efa\u7684 tar \u6587\u4ef6] filename...  ==\u6253\u5305\u538b\u7f29<\/span> tar [-z|-j|-J] [tv] [-f \u5df2\u6709\u7684 tar \u6587\u4ef6]              ==\u67e5\u770b\n$ tar [-z|-j|-J] [xv] [-f \u5df2\u6709\u7684 tar \u6587\u4ef6] [-C \u76ee\u5f55]    ==\u89e3\u538b\u7f29\n-z \uff1a\u4f7f\u7528 zip\uff1b\n-j \uff1a\u4f7f\u7528 bzip2\uff1b\n-J \uff1a\u4f7f\u7528 xz\uff1b\n-c \uff1a\u65b0\u5efa\u6253\u5305\u6587\u4ef6\uff1b\n-t \uff1a\u67e5\u770b\u6253\u5305\u6587\u4ef6\u91cc\u9762\u6709\u54ea\u4e9b\u6587\u4ef6\uff1b\n-x \uff1a\u89e3\u6253\u5305\u6216\u89e3\u538b\u7f29\u7684\u529f\u80fd\uff1b\n-v \uff1a\u5728\u538b\u7f29\/\u89e3\u538b\u7f29\u7684\u8fc7\u7a0b\u4e2d\uff0c\u663e\u793a\u6b63\u5728\u5904\u7406\u7684\u6587\u4ef6\u540d\uff1b\n-f : filename\uff1a\u8981\u5904\u7406\u7684\u6587\u4ef6\uff1b\n-C \u76ee\u5f55 \uff1a \u5728\u7279\u5b9a\u76ee\u5f55\u89e3\u538b\u7f29\u3002\n<\/pre>\n<table>\n<thead>\n<tr>\n<th align=\"center\">\u4f7f\u7528\u65b9\u5f0f<\/th>\n<th>\u547d\u4ee4<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td align=\"center\">\u6253\u5305\u538b\u7f29<\/td>\n<td>tar -jcv -f filename.tar.bz2 \u8981\u88ab\u538b\u7f29\u7684\u6587\u4ef6\u6216\u76ee\u5f55\u540d\u79f0<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">\u67e5 \u770b<\/td>\n<td>tar -jtv -f filename.tar.bz2<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">\u89e3\u538b\u7f29<\/td>\n<td>tar -jxv -f filename.tar.bz2 -C \u8981\u89e3\u538b\u7f29\u7684\u76ee\u5f55<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h1>\u4e03\u3001Bash<\/h1>\n<p>\u53ef\u4ee5\u901a\u8fc7 Shell \u8bf7\u6c42\u5185\u6838\u63d0\u4f9b\u670d\u52a1\uff0cBash \u6b63\u662f Shell \u7684\u4e00\u79cd\u3002<\/p>\n<h2>\u7279\u6027<\/h2>\n<ul>\n<li>\u547d\u4ee4\u5386\u53f2\uff1a\u8bb0\u5f55\u4f7f\u7528\u8fc7\u7684\u547d\u4ee4<\/li>\n<li>\u547d\u4ee4\u4e0e\u6587\u4ef6\u8865\u5168\uff1a\u5feb\u6377\u952e\uff1atab<\/li>\n<li>\u547d\u540d\u522b\u540d\uff1a\u4f8b\u5982 lm \u662f ls -al \u7684\u522b\u540d<\/li>\n<li>shell scripts<\/li>\n<li>\u901a\u914d\u7b26\uff1a\u4f8b\u5982 ls -l \/usr\/bin\/X&#42; \u5217\u51fa \/usr\/bin \u4e0b\u9762\u6240\u6709\u4ee5 X \u5f00\u5934\u7684\u6587\u4ef6<\/li>\n<\/ul>\n<h2>\u53d8\u91cf\u64cd\u4f5c<\/h2>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n<span class=\"katex math inline\">x=abc<\/span> echo <span class=\"katex math inline\">x<\/span> echo ${x}\n<\/pre>\n<p>\u53d8\u91cf\u5185\u5bb9\u5982\u679c\u6709\u7a7a\u683c\uff0c\u5fc5\u987b\u4f7f\u7528\u53cc\u5f15\u53f7\u6216\u8005\u5355\u5f15\u53f7\u3002<\/p>\n<ul>\n<li>\u53cc\u5f15\u53f7\u5185\u7684\u7279\u6b8a\u5b57\u7b26\u53ef\u4ee5\u4fdd\u7559\u539f\u672c\u7279\u6027\uff0c\u4f8b\u5982 x=&#8221;lang is \\$LANG&#8221;\uff0c\u5219 x \u7684\u503c\u4e3a lang is zh_TW.UTF-8\uff1b<\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n$ declare [-aixr] variable\n-a \uff1a \u5b9a\u4e49\u4e3a\u6570\u7ec4\u7c7b\u578b\n-i \uff1a \u5b9a\u4e49\u4e3a\u6574\u6570\u7c7b\u578b\n-x \uff1a \u5b9a\u4e49\u4e3a\u73af\u5883\u53d8\u91cf\n-r \uff1a \u5b9a\u4e49\u4e3a readonly \u7c7b\u578b\n<\/pre>\n<p>\u4f7f\u7528 [ ] \u6765\u5bf9\u6570\u7ec4\u8fdb\u884c\u7d22\u5f15\u64cd\u4f5c\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n<span class=\"katex math inline\">array[1]=a<\/span> array[2]=b\n<span class=\"katex math inline\">echo<\/span>{array[1]}\n<\/pre>\n<h2>\u6307\u4ee4\u641c\u7d22\u987a\u5e8f<\/h2>\n<ul>\n<li>\u4ee5\u7edd\u5bf9\u6216\u76f8\u5bf9\u8def\u5f84\u6765\u6267\u884c\u6307\u4ee4\uff0c\u4f8b\u5982 \/bin\/ls \u6216\u8005 .\/ls \uff1b<\/li>\n<li>\u7531\u522b\u540d\u627e\u5230\u8be5\u6307\u4ee4\u6765\u6267\u884c\uff1b<\/li>\n<li>\u7531 Bash \u5185\u7f6e\u7684\u6307\u4ee4\u6765\u6267\u884c\uff1b<\/li>\n<li>\u6309 \\$PATH \u53d8\u91cf\u6307\u5b9a\u7684\u641c\u7d22\u8def\u5f84\u7684\u987a\u5e8f\u627e\u5230\u7b2c\u4e00\u4e2a\u6307\u4ee4\u6765\u6267\u884c\u3002<\/li>\n<\/ul>\n<h2>\u6570\u636e\u6d41\u91cd\u5b9a\u5411<\/h2>\n<p>\u91cd\u5b9a\u5411\u6307\u7684\u662f\u4f7f\u7528\u6587\u4ef6\u4ee3\u66ff\u6807\u51c6\u8f93\u5165\u3001\u6807\u51c6\u8f93\u51fa\u548c\u6807\u51c6\u9519\u8bef\u8f93\u51fa\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th align=\"center\">1<\/th>\n<th align=\"center\">\u4ee3\u7801<\/th>\n<th align=\"center\">\u8fd0\u7b97\u7b26<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td align=\"center\">\u6807\u51c6\u8f93\u5165 (stdin)<\/td>\n<td align=\"center\">0<\/td>\n<td align=\"center\">&lt; \u6216 &lt;&lt;<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">\u6807\u51c6\u8f93\u51fa (stdout)<\/td>\n<td align=\"center\">1<\/td>\n<td align=\"center\">&gt; \u6216 >><\/td>\n<\/tr>\n<tr>\n<td align=\"center\">\u6807\u51c6\u9519\u8bef\u8f93\u51fa (stderr)<\/td>\n<td align=\"center\">2<\/td>\n<td align=\"center\">2> \u6216 2>><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5176\u4e2d\uff0c\u6709\u4e00\u4e2a\u7bad\u5934\u7684\u8868\u793a\u4ee5\u8986\u76d6\u7684\u65b9\u5f0f\u91cd\u5b9a\u5411\uff0c\u800c\u6709\u4e24\u4e2a\u7bad\u5934\u7684\u8868\u793a\u4ee5\u8ffd\u52a0\u7684\u65b9\u5f0f\u91cd\u5b9a\u5411\u3002<\/p>\n<p>\u53ef\u4ee5\u5c06\u4e0d\u9700\u8981\u7684\u6807\u51c6\u8f93\u51fa\u4ee5\u53ca\u6807\u51c6\u9519\u8bef\u8f93\u51fa\u91cd\u5b9a\u5411\u5230 \/dev\/null\uff0c\u76f8\u5f53\u4e8e\u6254\u8fdb\u5783\u573e\u7bb1\u3002<\/p>\n<p>\u5982\u679c\u9700\u8981\u5c06\u6807\u51c6\u8f93\u51fa\u4ee5\u53ca\u6807\u51c6\u9519\u8bef\u8f93\u51fa\u540c\u65f6\u91cd\u5b9a\u5411\u5230\u4e00\u4e2a\u6587\u4ef6\uff0c\u9700\u8981\u5c06\u67d0\u4e2a\u8f93\u51fa\u8f6c\u6362\u4e3a\u53e6\u4e00\u4e2a\u8f93\u51fa\uff0c\u4f8b\u5982 2>&amp;1 \u8868\u793a\u5c06\u6807\u51c6\u9519\u8bef\u8f93\u51fa\u8f6c\u6362\u4e3a\u6807\u51c6\u8f93\u51fa\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ find \/home -name .bashrc &amp;gt; list 2&amp;gt;&amp;amp;1\n<\/pre>\n<h1>\u516b\u3001\u7ba1\u9053\u6307\u4ee4<\/h1>\n<p>\u7ba1\u9053\u662f\u5c06\u4e00\u4e2a\u547d\u4ee4\u7684\u6807\u51c6\u8f93\u51fa\u4f5c\u4e3a\u53e6\u4e00\u4e2a\u547d\u4ee4\u7684\u6807\u51c6\u8f93\u5165\uff0c\u5728\u6570\u636e\u9700\u8981\u7ecf\u8fc7\u591a\u4e2a\u6b65\u9aa4\u7684\u5904\u7406\u4e4b\u540e\u624d\u80fd\u5f97\u5230\u6211\u4eec\u60f3\u8981\u7684\u5185\u5bb9\u65f6\u5c31\u53ef\u4ee5\u4f7f\u7528\u7ba1\u9053\u3002<\/p>\n<p>\u5728\u547d\u4ee4\u4e4b\u95f4\u4f7f\u7528 | \u5206\u9694\u5404\u4e2a\u7ba1\u9053\u547d\u4ee4\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ ls -al \/etc | less\n<\/pre>\n<h2>\u63d0\u53d6\u6307\u4ee4<\/h2>\n<p>cut \u5bf9\u6570\u636e\u8fdb\u884c\u5207\u5206\uff0c\u53d6\u51fa\u60f3\u8981\u7684\u90e8\u5206\u3002<\/p>\n<p>\u5207\u5206\u8fc7\u7a0b\u4e00\u884c\u4e00\u884c\u5730\u8fdb\u884c\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n$ cut\n-d \uff1a\u5206\u9694\u7b26\n-f \uff1a\u7ecf\u8fc7 -d \u5206\u9694\u540e\uff0c\u4f7f\u7528 -f n \u53d6\u51fa\u7b2c n \u4e2a\u533a\u95f4\n-c \uff1a\u4ee5\u5b57\u7b26\u4e3a\u5355\u4f4d\u53d6\u51fa\u533a\u95f4\n<\/pre>\n<p>\u793a\u4f8b 1\uff1alast \u663e\u793a\u767b\u5165\u8005\u7684\u4fe1\u606f\uff0c\u53d6\u51fa\u7528\u6237\u540d\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n<span class=\"katex math inline\">last\nroot pts\/1 192.168.201.101 Sat Feb 7 12:35 still logged in\nroot pts\/1 192.168.201.101 Fri Feb 6 12:13 - 18:46 (06:33)\nroot pts\/1 192.168.201.254 Thu Feb 5 22:37 - 23:53 (01:16)<\/span> last | cut -d &amp;#039; &amp;#039; -f 1\n<\/pre>\n<p>\u793a\u4f8b 2\uff1a\u5c06 export \u8f93\u51fa\u7684\u4fe1\u606f\uff0c\u53d6\u51fa\u7b2c 12 \u5b57\u7b26\u4ee5\u540e\u7684\u6240\u6709\u5b57\u7b26\u4e32\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n<span class=\"katex math inline\">export\ndeclare -x HISTCONTROL=&amp;quot;ignoredups&amp;quot;\ndeclare -x HISTSIZE=&amp;quot;1000&amp;quot;\ndeclare -x HOME=&amp;quot;\/home\/dmtsai&amp;quot;\ndeclare -x HOSTNAME=&amp;quot;study.centos.vbird&amp;quot;\n.....(\u5176\u4ed6\u7701\u7565).....<\/span> export | cut -c 12-\n<\/pre>\n<h2>\u6392\u5e8f\u6307\u4ee4<\/h2>\n<p><strong>sort<\/strong>  \u7528\u4e8e\u6392\u5e8f\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n$ sort [-fbMnrtuk] [file or stdin]\n-f \uff1a\u5ffd\u7565\u5927\u5c0f\u5199\n-b \uff1a\u5ffd\u7565\u6700\u524d\u9762\u7684\u7a7a\u683c\n-M \uff1a\u4ee5\u6708\u4efd\u7684\u540d\u5b57\u6765\u6392\u5e8f\uff0c\u4f8b\u5982 JAN\uff0cDEC\n-n \uff1a\u4f7f\u7528\u6570\u5b57\n-r \uff1a\u53cd\u5411\u6392\u5e8f\n-u \uff1a\u76f8\u5f53\u4e8e unique\uff0c\u91cd\u590d\u7684\u5185\u5bb9\u53ea\u51fa\u73b0\u4e00\u6b21\n-t \uff1a\u5206\u9694\u7b26\uff0c\u9ed8\u8ba4\u4e3a tab\n-k \uff1a\u6307\u5b9a\u6392\u5e8f\u7684\u533a\u95f4\n<\/pre>\n<p>\u793a\u4f8b\uff1a\/etc\/passwd \u6587\u4ef6\u5185\u5bb9\u4ee5 : \u6765\u5206\u9694\uff0c\u8981\u6c42\u4ee5\u7b2c\u4e09\u5217\u8fdb\u884c\u6392\u5e8f\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n$ cat \/etc\/passwd | sort -t &amp;#039;:&amp;#039; -k 3\nroot:x:0:0:root:\/root:\/bin\/bash\ndmtsai:x:1000:1000:dmtsai:\/home\/dmtsai:\/bin\/bash\nalex:x:1001:1002::\/home\/alex:\/bin\/bash\narod:x:1002:1003::\/home\/arod:\/bin\/bash\n<\/pre>\n<p><strong>uniq<\/strong>  \u53ef\u4ee5\u5c06\u91cd\u590d\u7684\u6570\u636e\u53ea\u53d6\u4e00\u4e2a\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n$ uniq [-ic]\n-i \uff1a\u5ffd\u7565\u5927\u5c0f\u5199\n-c \uff1a\u8fdb\u884c\u8ba1\u6570\n<\/pre>\n<p>\u793a\u4f8b\uff1a\u53d6\u5f97\u6bcf\u4e2a\u4eba\u7684\u767b\u5f55\u603b\u6b21\u6570<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n$ last | cut -d &amp;#039; &amp;#039; -f 1 | sort | uniq -c\n1\n6 (unknown\n47 dmtsai\n4 reboot\n7 root\n1 wtmp\n<\/pre>\n<h2>\u53cc\u5411\u8f93\u51fa\u91cd\u5b9a\u5411<\/h2>\n<p>\u8f93\u51fa\u91cd\u5b9a\u5411\u4f1a\u5c06\u8f93\u51fa\u5185\u5bb9\u91cd\u5b9a\u5411\u5230\u6587\u4ef6\u4e2d\uff0c\u800c  <strong>tee<\/strong>  \u4e0d\u4ec5\u80fd\u591f\u5b8c\u6210\u8fd9\u4e2a\u529f\u80fd\uff0c\u8fd8\u80fd\u4fdd\u7559\u5c4f\u5e55\u4e0a\u7684\u8f93\u51fa\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u4f7f\u7528 tee \u6307\u4ee4\uff0c\u4e00\u4e2a\u8f93\u51fa\u4f1a\u540c\u65f6\u4f20\u9001\u5230\u6587\u4ef6\u548c\u5c4f\u5e55\u4e0a\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n$ tee [-a] file\n<\/pre>\n<h2>\u5b57\u7b26\u8f6c\u6362\u6307\u4ee4<\/h2>\n<p><strong>tr<\/strong>  \u7528\u6765\u5220\u9664\u4e00\u884c\u4e2d\u7684\u5b57\u7b26\uff0c\u6216\u8005\u5bf9\u5b57\u7b26\u8fdb\u884c\u66ff\u6362\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n$ tr [-ds] SET1 ...\n-d \uff1a \u5220\u9664\u884c\u4e2d SET1 \u8fd9\u4e2a\u5b57\u7b26\u4e32\n<\/pre>\n<p>\u793a\u4f8b\uff0c\u5c06 last \u8f93\u51fa\u7684\u4fe1\u606f\u6240\u6709\u5c0f\u5199\u8f6c\u6362\u4e3a\u5927\u5199\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n$ last | tr &amp;#039;[a-z]&amp;#039; &amp;#039;[A-Z]&amp;#039;\n<\/pre>\n<p><strong>col<\/strong>  \u5c06 tab \u5b57\u7b26\u8f6c\u4e3a\u7a7a\u683c\u5b57\u7b26\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n$ col [-xb]\n-x \uff1a \u5c06 tab \u952e\u8f6c\u6362\u6210\u5bf9\u7b49\u7684\u7a7a\u683c\u952e\n<\/pre>\n<p><strong>expand<\/strong>  \u5c06 tab \u8f6c\u6362\u4e00\u5b9a\u6570\u91cf\u7684\u7a7a\u683c\uff0c\u9ed8\u8ba4\u662f 8 \u4e2a\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n$ expand [-t] file\n-t \uff1atab \u8f6c\u4e3a\u7a7a\u683c\u7684\u6570\u91cf\n<\/pre>\n<p><strong>join<\/strong>  \u5c06\u6709\u76f8\u540c\u6570\u636e\u7684\u90a3\u4e00\u884c\u5408\u5e76\u5728\u4e00\u8d77\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n$ join [-ti12] file1 file2\n-t \uff1a\u5206\u9694\u7b26\uff0c\u9ed8\u8ba4\u4e3a\u7a7a\u683c\n-i \uff1a\u5ffd\u7565\u5927\u5c0f\u5199\u7684\u5dee\u5f02\n-1 \uff1a\u7b2c\u4e00\u4e2a\u6587\u4ef6\u6240\u7528\u7684\u6bd4\u8f83\u5b57\u6bb5\n-2 \uff1a\u7b2c\u4e8c\u4e2a\u6587\u4ef6\u6240\u7528\u7684\u6bd4\u8f83\u5b57\u6bb5\n<\/pre>\n<p><strong>paste<\/strong>  \u76f4\u63a5\u5c06\u4e24\u884c\u7c98\u8d34\u5728\u4e00\u8d77\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n$ paste [-d] file1 file2\n-d \uff1a\u5206\u9694\u7b26\uff0c\u9ed8\u8ba4\u4e3a tab\n<\/pre>\n<h2>\u5206\u533a\u6307\u4ee4<\/h2>\n<p><strong>split<\/strong>  \u5c06\u4e00\u4e2a\u6587\u4ef6\u5212\u5206\u6210\u591a\u4e2a\u6587\u4ef6\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n$ split [-bl] file PREFIX\n-b \uff1a\u4ee5\u5927\u5c0f\u6765\u8fdb\u884c\u5206\u533a\uff0c\u53ef\u52a0\u5355\u4f4d\uff0c\u4f8b\u5982 b, k, m \u7b49\n-l \uff1a\u4ee5\u884c\u6570\u6765\u8fdb\u884c\u5206\u533a\u3002\n- PREFIX \uff1a\u5206\u533a\u6587\u4ef6\u7684\u524d\u5bfc\u540d\u79f0\n<\/pre>\n<h1>\u4e5d\u3001\u6b63\u5219\u8868\u8fbe\u5f0f<\/h1>\n<h2>grep<\/h2>\n<p>g\/re\/p\uff08globally search a regular expression and print)\uff0c\u4f7f\u7528\u6b63\u5219\u8868\u793a\u5f0f\u8fdb\u884c\u5168\u5c40\u67e5\u627e\u5e76\u6253\u5370\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n$ grep [-acinv] [--color=auto] \u641c\u5bfb\u5b57\u7b26\u4e32 filename\n-c \uff1a \u7edf\u8ba1\u4e2a\u6570\n-i \uff1a \u5ffd\u7565\u5927\u5c0f\u5199\n-n \uff1a \u8f93\u51fa\u884c\u53f7\n-v \uff1a \u53cd\u5411\u9009\u62e9\uff0c\u4e5f\u5c31\u662f\u663e\u793a\u51fa\u6ca1\u6709 \u641c\u5bfb\u5b57\u7b26\u4e32 \u5185\u5bb9\u7684\u90a3\u4e00\u884c\n--color=auto \uff1a\u627e\u5230\u7684\u5173\u952e\u5b57\u52a0\u989c\u8272\u663e\u793a\n<\/pre>\n<p>\u793a\u4f8b\uff1a\u628a\u542b\u6709 the \u5b57\u7b26\u4e32\u7684\u884c\u63d0\u53d6\u51fa\u6765\uff08\u6ce8\u610f\u9ed8\u8ba4\u4f1a\u6709 &#8211;color=auto \u9009\u9879\uff0c\u56e0\u6b64\u4ee5\u4e0b\u5185\u5bb9\u5728 Linux \u4e2d\u6709\u989c\u8272\u663e\u793a the \u5b57\u7b26\u4e32\uff09<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n$ grep -n &amp;#039;the&amp;#039; regular_express.txt\n8:I can&amp;#039;t finish the test.\n12:the symbol &amp;#039;*&amp;#039; is represented as start.\n15:You are the best is mean you are the no. 1.\n16:The world Happy is the same with &amp;quot;glad&amp;quot;.\n18:google is the best tools for search keyword\n<\/pre>\n<p>\u56e0\u4e3a { \u548c } \u5728 shell \u662f\u6709\u7279\u6b8a\u610f\u4e49\u7684\uff0c\u56e0\u6b64\u5fc5\u987b\u8981\u4f7f\u7528\u8f6c\u4e49\u5b57\u7b26\u8fdb\u884c\u8f6c\u4e49\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n$ grep -n &amp;#039;go\\{2,5\\}g&amp;#039; regular_express.txt\n<\/pre>\n<h2>printf<\/h2>\n<p>\u7528\u4e8e\u683c\u5f0f\u5316\u8f93\u51fa\u3002\u5b83\u4e0d\u5c5e\u4e8e\u7ba1\u9053\u547d\u4ee4\uff0c\u5728\u7ed9 printf \u4f20\u6570\u636e\u65f6\u9700\u8981\u4f7f\u7528 $( ) \u5f62\u5f0f\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n<span class=\"katex math inline\">printf &amp;#039;%10s %5i %5i %5i %8.2f \\n&amp;#039;<\/span>(cat printf.txt)\n    DmTsai    80    60    92    77.33\n     VBird    75    55    80    70.00\n       Ken    60    90    70    73.33\n<\/pre>\n<h2>awk<\/h2>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n$ last -n 5\ndmtsai pts\/0 192.168.1.100 Tue Jul 14 17:32 still logged in\ndmtsai pts\/0 192.168.1.100 Thu Jul 9 23:36 - 02:58 (03:22)\ndmtsai pts\/0 192.168.1.100 Thu Jul 9 17:23 - 23:36 (06:12)\ndmtsai pts\/0 192.168.1.100 Thu Jul 9 08:02 - 08:17 (00:14)\ndmtsai tty1 Fri May 29 11:55 - 12:11 (00:15)\n<\/pre>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n<span class=\"katex math inline\">last -n 5 | awk &amp;#039;{print<\/span>1 &amp;quot;\\t&amp;quot; $3}&amp;#039;\n<\/pre>\n<p>\u53ef\u4ee5\u6839\u636e\u5b57\u6bb5\u7684\u67d0\u4e9b\u6761\u4ef6\u8fdb\u884c\u5339\u914d\uff0c\u4f8b\u5982\u5339\u914d\u5b57\u6bb5\u5c0f\u4e8e\u67d0\u4e2a\u503c\u7684\u90a3\u4e00\u884c\u6570\u636e\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n$ awk &amp;#039;\u6761\u4ef6\u7c7b\u578b 1 {\u52a8\u4f5c 1} \u6761\u4ef6\u7c7b\u578b 2 {\u52a8\u4f5c 2} ...&amp;#039; filename\n<\/pre>\n<p>\u793a\u4f8b\uff1a\/etc\/passwd \u6587\u4ef6\u7b2c\u4e09\u4e2a\u5b57\u6bb5\u4e3a UID\uff0c\u5bf9 UID \u5c0f\u4e8e 10 \u7684\u6570\u636e\u8fdb\u884c\u5904\u7406\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n<span class=\"katex math inline\">cat \/etc\/passwd | awk &amp;#039;BEGIN {FS=&amp;quot;:&amp;quot;}<\/span>3 &amp;lt; 10 {print <span class=\"katex math inline\">1 &amp;quot;\\t &amp;quot;<\/span>3}&amp;#039;\nroot 0\nbin 1\ndaemon 2\n<\/pre>\n<p>awk \u53d8\u91cf\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th align=\"center\">\u53d8\u91cf\u540d\u79f0<\/th>\n<th>\u4ee3\u8868\u610f\u4e49<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td align=\"center\">NF<\/td>\n<td>\u6bcf\u4e00\u884c\u62e5\u6709\u7684\u5b57\u6bb5\u603b\u6570<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">NR<\/td>\n<td>\u76ee\u524d\u6240\u5904\u7406\u7684\u662f\u7b2c\u51e0\u884c\u6570\u636e<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">FS<\/td>\n<td>\u76ee\u524d\u7684\u5206\u9694\u5b57\u7b26\uff0c\u9ed8\u8ba4\u662f\u7a7a\u683c\u952e<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u793a\u4f8b\uff1a\u663e\u793a\u6b63\u5728\u5904\u7406\u7684\u884c\u53f7\u4ee5\u53ca\u6bcf\u4e00\u884c\u6709\u591a\u5c11\u5b57\u6bb5<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n<span class=\"katex math inline\">last -n 5 | awk &amp;#039;{print<\/span>1 &amp;quot;\\t lines: &amp;quot; NR &amp;quot;\\t columns: &amp;quot; NF}&amp;#039;\ndmtsai lines: 1 columns: 10\ndmtsai lines: 2 columns: 10\ndmtsai lines: 3 columns: 10\ndmtsai lines: 4 columns: 10\ndmtsai lines: 5 columns: 9\n<\/pre>\n<h1>\u5341\u3001\u8fdb\u7a0b\u7ba1\u7406<\/h1>\n<h2>\u67e5\u770b\u8fdb\u7a0b<\/h2>\n<h3>1. ps<\/h3>\n<p>\u67e5\u770b\u67d0\u4e2a\u65f6\u95f4\u70b9\u7684\u8fdb\u7a0b\u4fe1\u606f<\/p>\n<p>\u793a\u4f8b\u4e00\uff1a\u67e5\u770b\u81ea\u5df1\u7684\u8fdb\u7a0b<\/p>\n<p># ps -l<\/p>\n<p>\u793a\u4f8b\u4e8c\uff1a\u67e5\u770b\u7cfb\u7edf\u6240\u6709\u8fdb\u7a0b<\/p>\n<p># ps aux<\/p>\n<p>\u793a\u4f8b\u4e09\uff1a\u67e5\u770b\u7279\u5b9a\u7684\u8fdb\u7a0b<\/p>\n<p># ps aux | grep threadx<\/p>\n<h3>2. pstree<\/h3>\n<p>\u67e5\u770b\u8fdb\u7a0b\u6811<\/p>\n<p>\u793a\u4f8b\uff1a\u67e5\u770b\u6240\u6709\u8fdb\u7a0b\u6811<\/p>\n<p># pstree -A<\/p>\n<h3>3. top<\/h3>\n<p>\u5b9e\u65f6\u663e\u793a\u8fdb\u7a0b\u4fe1\u606f<\/p>\n<p>\u793a\u4f8b\uff1a\u4e24\u79d2\u949f\u5237\u65b0\u4e00\u6b21<\/p>\n<p># top -d 2<\/p>\n<h3>4. netstat<\/h3>\n<p>\u67e5\u770b\u5360\u7528\u7aef\u53e3\u7684\u8fdb\u7a0b<\/p>\n<p>\u793a\u4f8b\uff1a\u67e5\u770b\u7279\u5b9a\u7aef\u53e3\u7684\u8fdb\u7a0b<\/p>\n<p># netstat -anp | grep port<\/p>\n<h2>\u8fdb\u7a0b\u72b6\u6001<\/h2>\n<p>| \u72b6\u6001 | \u8bf4\u660e |<br \/>\n| :&#8212;: | &#8212; |<br \/>\n| R | running or runnable (on run queue) |<br \/>\n| D | uninterruptible sleep (usually I\/O) |<br \/>\n| S | interruptible sleep (waiting for an event to complete) |<br \/>\n| Z | zombie (terminated but not reaped by its parent) |<br \/>\n| T | stopped (either by a job control signal or because it is being traced) |<br \/>\n<\/p>\n<div align=\"center\"> <img src=\"pics\/76a49594323247f21c9b3a69945445ee.png\" width=\"\"\/> <\/div>\n<p><\/p>\n<h2>SIGCHLD<\/h2>\n<p>\u5f53\u4e00\u4e2a\u5b50\u8fdb\u7a0b\u6539\u53d8\u4e86\u5b83\u7684\u72b6\u6001\u65f6\uff08\u505c\u6b62\u8fd0\u884c\uff0c\u7ee7\u7eed\u8fd0\u884c\u6216\u8005\u9000\u51fa\uff09\uff0c\u6709\u4e24\u4ef6\u4e8b\u4f1a\u53d1\u751f\u5728\u7236\u8fdb\u7a0b\u4e2d\uff1a<\/p>\n<ul>\n<li>\u5f97\u5230 SIGCHLD \u4fe1\u53f7\uff1b<\/li>\n<li>waitpid() \u6216\u8005 wait() \u8c03\u7528\u4f1a\u8fd4\u56de\u3002<\/li>\n<\/ul>\n<p>\u5176\u4e2d\u5b50\u8fdb\u7a0b\u53d1\u9001\u7684 SIGCHLD \u4fe1\u53f7\u5305\u542b\u4e86\u5b50\u8fdb\u7a0b\u7684\u4fe1\u606f\uff0c\u6bd4\u5982\u8fdb\u7a0b ID\u3001\u8fdb\u7a0b\u72b6\u6001\u3001\u8fdb\u7a0b\u4f7f\u7528 CPU \u7684\u65f6\u95f4\u7b49\u3002<\/p>\n<p>\u5728\u5b50\u8fdb\u7a0b\u9000\u51fa\u65f6\uff0c\u5b83\u7684\u8fdb\u7a0b\u63cf\u8ff0\u7b26\u4e0d\u4f1a\u7acb\u5373\u91ca\u653e\uff0c\u8fd9\u662f\u4e3a\u4e86\u8ba9\u7236\u8fdb\u7a0b\u5f97\u5230\u5b50\u8fdb\u7a0b\u4fe1\u606f\uff0c\u7236\u8fdb\u7a0b\u901a\u8fc7 wait() \u548c waitpid() \u6765\u83b7\u5f97\u4e00\u4e2a\u5df2\u7ecf\u9000\u51fa\u7684\u5b50\u8fdb\u7a0b\u7684\u4fe1\u606f\u3002<\/p>\n<div align=\"center\"> <img src=\"pics\/flow.png\" width=\"\"\/> <\/div>\n<p><\/p>\n<h2>wait()<\/h2>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\npid_t wait(int *status)\n<\/pre>\n<p>\u7236\u8fdb\u7a0b\u8c03\u7528 wait() \u4f1a\u4e00\u76f4\u963b\u585e\uff0c\u76f4\u5230\u6536\u5230\u4e00\u4e2a\u5b50\u8fdb\u7a0b\u9000\u51fa\u7684 SIGCHLD \u4fe1\u53f7\uff0c\u4e4b\u540e wait() \u51fd\u6570\u4f1a\u9500\u6bc1\u5b50\u8fdb\u7a0b\u5e76\u8fd4\u56de\u3002<\/p>\n<p>\u5982\u679c\u6210\u529f\uff0c\u8fd4\u56de\u88ab\u6536\u96c6\u7684\u5b50\u8fdb\u7a0b\u7684\u8fdb\u7a0b ID\uff1b\u5982\u679c\u8c03\u7528\u8fdb\u7a0b\u6ca1\u6709\u5b50\u8fdb\u7a0b\uff0c\u8c03\u7528\u5c31\u4f1a\u5931\u8d25\uff0c\u6b64\u65f6\u8fd4\u56de -1\uff0c\u540c\u65f6 errno \u88ab\u7f6e\u4e3a ECHILD\u3002<\/p>\n<p>\u53c2\u6570 status \u7528\u6765\u4fdd\u5b58\u88ab\u6536\u96c6\u7684\u5b50\u8fdb\u7a0b\u9000\u51fa\u65f6\u7684\u4e00\u4e9b\u72b6\u6001\uff0c\u5982\u679c\u5bf9\u8fd9\u4e2a\u5b50\u8fdb\u7a0b\u662f\u5982\u4f55\u6b7b\u6389\u7684\u6beb\u4e0d\u5728\u610f\uff0c\u53ea\u60f3\u628a\u8fd9\u4e2a\u5b50\u8fdb\u7a0b\u6d88\u706d\u6389\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u8fd9\u4e2a\u53c2\u6570\u4e3a NULL\u3002<\/p>\n<h2>waitpid()<\/h2>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\npid_t waitpid(pid_t pid, int *status, int options)\n<\/pre>\n<p>\u4f5c\u7528\u548c wait() \u5b8c\u5168\u76f8\u540c\uff0c\u4f46\u662f\u591a\u4e86\u4e24\u4e2a\u53ef\u7531\u7528\u6237\u63a7\u5236\u7684\u53c2\u6570 pid \u548c options\u3002<\/p>\n<p>pid \u53c2\u6570\u6307\u793a\u4e00\u4e2a\u5b50\u8fdb\u7a0b\u7684 ID\uff0c\u8868\u793a\u53ea\u5173\u5fc3\u8fd9\u4e2a\u5b50\u8fdb\u7a0b\u9000\u51fa\u7684 SIGCHLD \u4fe1\u53f7\u3002\u5982\u679c pid=-1 \u65f6\uff0c\u90a3\u4e48\u548c wait() \u4f5c\u7528\u76f8\u540c\uff0c\u90fd\u662f\u5173\u5fc3\u6240\u6709\u5b50\u8fdb\u7a0b\u9000\u51fa\u7684 SIGCHLD \u4fe1\u53f7\u3002<\/p>\n<p>options \u53c2\u6570\u4e3b\u8981\u6709 WNOHANG \u548c WUNTRACED \u4e24\u4e2a\u9009\u9879\uff0cWNOHANG \u53ef\u4ee5\u4f7f waitpid() \u8c03\u7528\u53d8\u6210\u975e\u963b\u585e\u7684\uff0c\u4e5f\u5c31\u662f\u8bf4\u5b83\u4f1a\u7acb\u5373\u8fd4\u56de\uff0c\u7236\u8fdb\u7a0b\u53ef\u4ee5\u7ee7\u7eed\u6267\u884c\u5176\u5b83\u4efb\u52a1\u3002<\/p>\n<h2>\u5b64\u513f\u8fdb\u7a0b<\/h2>\n<p>\u4e00\u4e2a\u7236\u8fdb\u7a0b\u9000\u51fa\uff0c\u800c\u5b83\u7684\u4e00\u4e2a\u6216\u591a\u4e2a\u5b50\u8fdb\u7a0b\u8fd8\u5728\u8fd0\u884c\uff0c\u90a3\u4e48\u8fd9\u4e9b\u5b50\u8fdb\u7a0b\u5c06\u6210\u4e3a\u5b64\u513f\u8fdb\u7a0b\u3002<\/p>\n<p>\u5b64\u513f\u8fdb\u7a0b\u5c06\u88ab init \u8fdb\u7a0b\uff08\u8fdb\u7a0b\u53f7\u4e3a 1\uff09\u6240\u6536\u517b\uff0c\u5e76\u7531 init \u8fdb\u7a0b\u5bf9\u5b83\u4eec\u5b8c\u6210\u72b6\u6001\u6536\u96c6\u5de5\u4f5c\u3002<\/p>\n<p>\u7531\u4e8e\u5b64\u513f\u8fdb\u7a0b\u4f1a\u88ab init \u8fdb\u7a0b\u6536\u517b\uff0c\u6240\u4ee5\u5b64\u513f\u8fdb\u7a0b\u4e0d\u4f1a\u5bf9\u7cfb\u7edf\u9020\u6210\u5371\u5bb3\u3002<\/p>\n<h2>\u50f5\u5c38\u8fdb\u7a0b<\/h2>\n<p>\u4e00\u4e2a\u5b50\u8fdb\u7a0b\u7684\u8fdb\u7a0b\u63cf\u8ff0\u7b26\u5728\u5b50\u8fdb\u7a0b\u9000\u51fa\u65f6\u4e0d\u4f1a\u91ca\u653e\uff0c\u53ea\u6709\u5f53\u7236\u8fdb\u7a0b\u901a\u8fc7 wait() \u6216 waitpid() \u83b7\u53d6\u4e86\u5b50\u8fdb\u7a0b\u4fe1\u606f\u540e\u624d\u4f1a\u91ca\u653e\u3002\u5982\u679c\u5b50\u8fdb\u7a0b\u9000\u51fa\uff0c\u800c\u7236\u8fdb\u7a0b\u5e76\u6ca1\u6709\u8c03\u7528 wait() \u6216 waitpid()\uff0c\u90a3\u4e48\u5b50\u8fdb\u7a0b\u7684\u8fdb\u7a0b\u63cf\u8ff0\u7b26\u4ecd\u7136\u4fdd\u5b58\u5728\u7cfb\u7edf\u4e2d\uff0c\u8fd9\u79cd\u8fdb\u7a0b\u79f0\u4e4b\u4e3a\u50f5\u5c38\u8fdb\u7a0b\u3002<\/p>\n<p>\u50f5\u5c38\u8fdb\u7a0b\u901a\u8fc7 ps \u547d\u4ee4\u663e\u793a\u51fa\u6765\u7684\u72b6\u6001\u4e3a Z\uff08zombie\uff09\u3002<\/p>\n<p>\u7cfb\u7edf\u6240\u80fd\u4f7f\u7528\u7684\u8fdb\u7a0b\u53f7\u662f\u6709\u9650\u7684\uff0c\u5982\u679c\u4ea7\u751f\u5927\u91cf\u50f5\u5c38\u8fdb\u7a0b\uff0c\u5c06\u56e0\u4e3a\u6ca1\u6709\u53ef\u7528\u7684\u8fdb\u7a0b\u53f7\u800c\u5bfc\u81f4\u7cfb\u7edf\u4e0d\u80fd\u4ea7\u751f\u65b0\u7684\u8fdb\u7a0b\u3002<\/p>\n<p>\u8981\u6d88\u706d\u7cfb\u7edf\u4e2d\u5927\u91cf\u7684\u50f5\u5c38\u8fdb\u7a0b\uff0c\u53ea\u9700\u8981\u5c06\u5176\u7236\u8fdb\u7a0b\u6740\u6b7b\uff0c\u6b64\u65f6\u50f5\u5c38\u8fdb\u7a0b\u5c31\u4f1a\u53d8\u6210\u5b64\u513f\u8fdb\u7a0b\uff0c\u4ece\u800c\u88ab init \u6240\u6536\u517b\uff0c\u8fd9\u6837 init \u5c31\u4f1a\u91ca\u653e\u6240\u6709\u7684\u50f5\u5c38\u8fdb\u7a0b\u6240\u5360\u6709\u7684\u8d44\u6e90\uff0c\u4ece\u800c\u7ed3\u675f\u50f5\u5c38\u8fdb\u7a0b\u3002<\/p>\n<h1>\u53c2\u8003\u8d44\u6599<\/h1>\n<ul>\n<li>\u9e1f\u54e5. \u9e1f \u54e5 \u7684 Linux \u79c1 \u623f \u83dc \u57fa \u7840 \u7bc7 \u7b2c \u4e09 \u7248[J]. 2009.<\/li>\n<li><a href=\"https:\/\/www.ibm.com\/developerworks\/cn\/linux\/l-cn-rpmdpkg\/index.html\" target=\"_blank\" rel=\"noopener\">Linux \u5e73\u53f0\u4e0a\u7684\u8f6f\u4ef6\u5305\u7ba1\u7406<\/a><\/li>\n<li><a href=\"http:\/\/liubigbin.github.io\/2016\/03\/11\/Linux-%E4%B9%8B%E5%AE%88%E6%8A%A4%E8%BF%9B%E7%A8%8B%E3%80%81%E5%83%B5%E6%AD%BB%E8%BF%9B%E7%A8%8B%E4%B8%8E%E5%AD%A4%E5%84%BF%E8%BF%9B%E7%A8%8B\/\" target=\"_blank\" rel=\"noopener\">Linux \u4e4b\u5b88\u62a4\u8fdb\u7a0b\u3001\u50f5\u6b7b\u8fdb\u7a0b\u4e0e\u5b64\u513f\u8fdb\u7a0b<\/a><\/li>\n<li><a href=\"https:\/\/stackoverflow.com\/questions\/185899\/what-is-the-difference-between-a-symbolic-link-and-a-hard-link\" target=\"_blank\" rel=\"noopener\">What is the difference between a symbolic link and a hard link?<\/a><\/li>\n<li><a href=\"https:\/\/idea.popcount.org\/2012-12-11-linux-process-states\/\" target=\"_blank\" rel=\"noopener\">Linux process states<\/a><\/li>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/GUID_Partition_Table\" target=\"_blank\" rel=\"noopener\">GUID Partition Table<\/a><\/li>\n<li><a href=\"https:\/\/blog.csdn.net\/kevinhg\/article\/details\/7001719\" target=\"_blank\" rel=\"noopener\">\u8be6\u89e3 wait \u548c waitpid \u51fd\u6570<\/a><\/li>\n<li><a href=\"https:\/\/blog.csdn.net\/tianlesoftware\/article\/details\/6009110\" target=\"_blank\" rel=\"noopener\">IDE\u3001SATA\u3001SCSI\u3001SAS\u3001FC\u3001SSD \u786c\u76d8\u7c7b\u578b\u4ecb\u7ecd<\/a><\/li>\n<li><a href=\"http:\/\/www.mpchunter.com\/s3000\/akai-ib-301s-scsi-interface-for-s2800s3000\/\" target=\"_blank\" rel=\"noopener\">Akai IB-301S SCSI Interface for S2800,S3000<\/a><\/li>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/Parallel_ATA\" target=\"_blank\" rel=\"noopener\">Parallel ATA<\/a><\/li>\n<li><a href=\"http:\/\/www.thessdreview.com\/our-reviews\/adata-xpg-sx900-256gb-sata-3-ssd-review-expanded-capacity-and-sandforce-driven-speed\/4\/\" target=\"_blank\" rel=\"noopener\">ADATA XPG SX900 256GB SATA 3 SSD Review \u2013 Expanded Capacity and SandForce Driven Speed<\/a><\/li>\n<li><a href=\"https:\/\/blogs.cisco.com\/datacenter\/decoding-ucs-invicta-part-1\" target=\"_blank\" rel=\"noopener\">Decoding UCS Invicta \u2013 Part 1<\/a><\/li>\n<li><a href=\"https:\/\/zh.wikipedia.org\/wiki\/%E7%A1%AC%E7%9B%98\" target=\"_blank\" rel=\"noopener\">\u786c\u76d8<\/a><\/li>\n<li><a href=\"http:\/\/www.differencebetween.info\/difference-between-sas-and-sata\" target=\"_blank\" rel=\"noopener\">Difference between SAS and SATA<\/a><\/li>\n<li><a href=\"https:\/\/zh.wikipedia.org\/wiki\/BIOS\" target=\"_blank\" rel=\"noopener\">BIOS<\/a><\/li>\n<li><a href=\"https:\/\/www.cs.rutgers.edu\/\\~pxk\/416\/notes\/13-fs-studies.html\" target=\"_blank\" rel=\"noopener\">File system design case studies<\/a><\/li>\n<li><a href=\"https:\/\/classes.soe.ucsc.edu\/cmps111\/Fall08\/proj4.shtml\" target=\"_blank\" rel=\"noopener\">Programming Project #4<\/a><\/li>\n<li><a href=\"http:\/\/web.cs.ucla.edu\/classes\/fall14\/cs111\/scribe\/11a\/index.html\" target=\"_blank\" rel=\"noopener\">FILE SYSTEM DESIGN<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u53c2\u8003 \u4e00\u3001\u5e38\u7528\u64cd\u4f5c\u4ee5\u53ca\u6982\u5ff5 \u5feb\u6377\u952e Tab\uff1a\u547d\u4ee4\u548c\u6587\u4ef6\u540d\u8865\u5168\uff1b Ctrl+C\uff1a\u4e2d\u65ad\u6b63\u5728\u8fd0\u884c\u7684\u7a0b\u5e8f\uff1b Ctrl+<a href=\"https:\/\/www.ccagml.com\/?p=270\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Linux\u57fa\u7840\u77e5\u8bc6<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[21,18],"tags":[],"_links":{"self":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/270"}],"collection":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=270"}],"version-history":[{"count":3,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/270\/revisions"}],"predecessor-version":[{"id":289,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/270\/revisions\/289"}],"wp:attachment":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=270"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=270"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}