{"id":102216,"date":"2026-09-08T11:12:44","date_gmt":"2026-09-08T03:12:44","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/102216.html"},"modified":"2026-09-08T11:12:44","modified_gmt":"2026-09-08T03:12:44","slug":"%e3%80%90%e7%9f%a5%e8%af%86%e8%ae%b2%e8%a7%a3%e3%80%91-linux%e7%8e%af%e5%a2%83%e5%8f%98%e9%87%8f%e7%9a%84%e8%ae%a4%e8%af%86%e4%b8%8e%e4%bd%bf%e7%94%a8","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/102216.html","title":{"rendered":"\u3010\u77e5\u8bc6\u8bb2\u89e3\u3011 Linux\u73af\u5883\u53d8\u91cf\u7684\u8ba4\u8bc6\u4e0e\u4f7f\u7528"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260908031241-6a9f7d290cf18.jpg\" \/><\/p>\n<hr \/>\n<p id=\"main-toc\">\u76ee\u5f55<\/p>\n<p id=\"%E5%89%8D%E8%A8%80-toc\" style=\"margin-left:0px\">\u524d\u8a00<\/p>\n<p id=\"Part1.%20main%E5%87%BD%E6%95%B0%E5%91%BD%E4%BB%A4%E8%A1%8C%E5%8F%82%E6%95%B0-toc\" style=\"margin-left:0px\">Part1. main\u51fd\u6570\u547d\u4ee4\u884c\u53c2\u6570<\/p>\n<p id=\"Part2.%20PATH%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F-toc\" style=\"margin-left:0px\">Part2. PATH\u73af\u5883\u53d8\u91cf<\/p>\n<p id=\"Part2.1.%20PATH%E4%BD%9C%E7%94%A8-toc\" style=\"margin-left:40px\">Part2.1. PATH\u4f5c\u7528<\/p>\n<p id=\"Part2.2.%20%E6%9F%A5%E7%9C%8BPATH-toc\" style=\"margin-left:40px\">Part2.2. \u67e5\u770bPATH<\/p>\n<p id=\"Part2.3.%20shell%E6%89%A7%E8%A1%8C%E4%B8%80%E6%9D%A1%E5%91%BD%E4%BB%A4%E6%B5%81%E7%A8%8B-toc\" style=\"margin-left:40px\">Part2.3. shell\u6267\u884c\u4e00\u6761\u547d\u4ee4\u6d41\u7a0b<\/p>\n<p id=\"Part3.%20%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%E5%9F%BA%E7%A1%80%E6%A6%82%E5%BF%B5-toc\" style=\"margin-left:0px\">Part3. \u73af\u5883\u53d8\u91cf\u57fa\u7840\u6982\u5ff5<\/p>\n<p id=\"Part4.%20shell%E6%93%8D%E4%BD%9C%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F-toc\" style=\"margin-left:0px\">Part4. shell\u64cd\u4f5c\u73af\u5883\u53d8\u91cf<\/p>\n<p id=\"Part5.%20C%E8%AF%AD%E8%A8%80%E6%93%8D%E4%BD%9C%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F-toc\" style=\"margin-left:0px\">Part5. C\u8bed\u8a00\u64cd\u4f5c\u73af\u5883\u53d8\u91cf<\/p>\n<p id=\"Part5.1.%20main%E5%87%BD%E6%95%B0%E5%8F%82%E6%95%B0%20envp-toc\" style=\"margin-left:40px\">Part5.1. main\u51fd\u6570\u53c2\u6570 envp<\/p>\n<p id=\"Part5.2.%20getenv%20%E8%8E%B7%E5%8F%96%E6%8C%87%E5%AE%9A%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F-toc\" style=\"margin-left:40px\">Part5.2. getenv \u83b7\u53d6\u6307\u5b9a\u73af\u5883\u53d8\u91cf<\/p>\n<p id=\"Part5.3.%20extern%20environ%20%E5%85%A8%E5%B1%80%E5%8F%98%E9%87%8F-toc\" style=\"margin-left:40px\">Part5.3. extern environ \u5168\u5c40\u53d8\u91cf<\/p>\n<p id=\"Part6.%20%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%E7%9A%84%E7%89%B9%E6%80%A7-toc\" style=\"margin-left:0px\">Part6. \u73af\u5883\u53d8\u91cf\u7684\u7279\u6027<\/p>\n<p id=\"Part7.%20shell%E8%84%9A%E6%9C%AC-toc\" style=\"margin-left:0px\">Part7. shell\u811a\u672c<\/p>\n<p id=\"Part8.%20%E8%BF%9B%E7%A8%8B%E5%9C%B0%E5%9D%80%E7%A9%BA%E9%97%B4%E8%A1%A5%E5%85%85-toc\" style=\"margin-left:0px\">Part8. \u8fdb\u7a0b\u5730\u5740\u7a7a\u95f4\u8865\u5145<\/p>\n<p id=\"Part9.%20%E7%BB%93%E8%AF%AD-toc\" style=\"margin-left:0px\">Part9. \u7ed3\u8bed<\/p>\n<hr id=\"hr-toc\" \/>\n<h2>\u524d\u8a00<\/h2>\n<p>\u00a0 \u5728Linux\u4e2d\u73af\u5883\u53d8\u91cf\u662f\u975e\u5e38\u91cd\u8981\u7684\u5b58\u5728&#xff0c;\u63a5\u4e0b\u6765\u6765\u8ddf\u968f\u5c0f\u7f16\u7684\u89c6\u89d2\u6765\u7406\u89e3\u4e00\u4e0b\u5427\u3002<\/p>\n<hr \/>\n<p style=\"text-align:center\"><span style=\"color:#4da8ee\">let&#039;s go!!!!!!!!<\/span><\/p>\n<hr \/>\n<h2 id=\"Part1.%20main%E5%87%BD%E6%95%B0%E5%91%BD%E4%BB%A4%E8%A1%8C%E5%8F%82%E6%95%B0\" style=\"background-color:transparent\">Part1. main\u51fd\u6570\u547d\u4ee4\u884c\u53c2\u6570<\/h2>\n<p> int main(int argc, char *argv[])<br \/>\n{<br \/>\n\u00a0 \u00a0 for(int i &#061; 0; i &lt; argc; i&#043;&#043;)<br \/>\n\u00a0 \u00a0 {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 printf(&#034;argv[%d]: %s\\\\n&#034;, i, argv[i]);<br \/>\n\u00a0 \u00a0 }<br \/>\n\u00a0 \u00a0 return 0;<br \/>\n}<br \/>\n\/\/argc&#xff1a;argument count&#xff0c;\u547d\u4ee4\u884c\u53c2\u6570\u4e2a\u6570\u3002<\/p>\n<p>\/\/argv&#xff1a;argument vector&#xff0c;\u5b57\u7b26\u4e32\u6570\u7ec4&#xff0c;\u5b58\u653e\u6bcf\u4e00\u4e2a\u547d\u4ee4\u53c2\u6570\u3002 <\/p>\n<p>\u793a\u4f8b&#xff1a;.\/exe a b<\/p>\n<\/p>\n<p>\u2022 argc &#061; 3<\/p>\n<p>\u2022 argv[0] &#061; &#034;.\/exe&#034;&#xff0c;\u6c38\u8fdc\u662f\u7a0b\u5e8f\u672c\u8eab\u540d\u5b57<\/p>\n<p>\u2022 argv[1] &#061; &#034;a&#034;<\/p>\n<p>\u2022 argv[2] &#061; &#034;b&#034;<\/p>\n<p>\u2022 argv[3] &#061; NULL&#xff0c;\u6570\u7ec4\u672b\u5c3e\u4ee5NULL\u7ed3\u5c3e\u3002<\/p>\n<p> <span style=\"color:#ed7976\">shell\u628a\u8f93\u5165\u7684\u4e00\u6574\u884c\u5b57\u7b26\u4e32&#xff0c;\u4ee5\u7a7a\u683c\u5206\u5272&#xff0c;\u5f97\u5230argv\u6570\u7ec4\u4f20\u7ed9main\u51fd\u6570<\/span>\u3002<\/p>\n<p> \u5f88\u591a\u547d\u4ee4\u884c\u7a0b\u5e8f<span style=\"color:#faa572\">\u5229\u7528argv\u505a\u4e0d\u540c\u529f\u80fd&#xff0c;\u4f8b\u5982 ls -a&#xff0c;\u7a0b\u5e8f\u8bfb\u53d6argv[1]\u505a\u5206\u652f\u5224\u65ad<\/span>\u3002<\/p>\n<hr \/>\n<h2 id=\"Part2.%20PATH%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F\" style=\"background-color:transparent\">Part2. PATH\u73af\u5883\u53d8\u91cf<\/h2>\n<h3 id=\"Part2.1.%20PATH%E4%BD%9C%E7%94%A8\">Part2.1. PATH\u4f5c\u7528<\/h3>\n<p>PATH<span style=\"color:#faa572\">\u4fdd\u5b58\u82e5\u5e72\u76ee\u5f55\u8def\u5f84<\/span>&#xff0c;shell\u6267\u884c\u547d\u4ee4\u65f6&#xff0c;\u4f1a<span style=\"color:#ed7976\">\u4f9d\u6b21\u53bbPATH\u5185\u7684\u76ee\u5f55\u67e5\u627e\u53ef\u6267\u884c\u7a0b\u5e8f<\/span>\u3002<\/p>\n<p> \u5982\u679c<span style=\"color:#98c091\">\u7a0b\u5e8f\u4e0d\u5728PATH\u76ee\u5f55&#xff0c;\u6267\u884c\u5c31\u5fc5\u987b\u5199 .\/\u7a0b\u5e8f\u540d<\/span>&#xff1b;\u628a<span style=\"color:#6eaad7\">\u7a0b\u5e8f\u6240\u5728\u76ee\u5f55\u52a0\u5165PATH\u4e4b\u540e&#xff0c;\u53ef\u4ee5\u76f4\u63a5\u8f93\u5165\u7a0b\u5e8f\u540d\u5b57\u8fd0\u884c\u3002<\/span><\/p>\n<hr \/>\n<h3 id=\"Part2.2.%20%E6%9F%A5%E7%9C%8BPATH\" style=\"background-color:transparent\">Part2.2. \u67e5\u770bPATH<\/h3>\n<p><span style=\"color:#be191c\">echo $PATH<\/span><\/p>\n<p> \u591a\u4e2a\u8def\u5f84\u7528<span style=\"color:#79c6cd\">\u5192\u53f7:<\/span>\u5206\u5272 <span style=\"color:#be191c\">\/usr\/local\/bin:\/usr\/bin:\/bin<\/span><\/p>\n<p> \u4e34\u65f6\u6dfb\u52a0\u8def\u5f84\u5230PATH&#xff1a; X\u4e3a\u4f60\u7684\u53ef\u6267\u884c\u6587\u4ef6\u6240\u5728<span style=\"color:#faa572\">\u7edd\u5bf9\u8def\u5f84<\/span> <span style=\"color:#be191c\">PATH&#061;$PATH:X<\/span><\/p>\n<p> <span style=\"color:#9c8ec1\">$PATH\u4ee3\u8868\u4fdd\u7559\u7cfb\u7edf\u539f\u6709\u8def\u5f84&#xff0c;\u8ffd\u52a0\u65b0\u76ee\u5f55X<\/span>\u3002 \u8fd9\u662f<span style=\"color:#e6b223\">\u4e34\u65f6\u4fee\u6539&#xff0c;\u5173\u95ed\u7ec8\u7aef\u5c31\u5931\u6548<\/span>\u3002<\/p>\n<hr \/>\n<h3 id=\"Part2.3.%20shell%E6%89%A7%E8%A1%8C%E4%B8%80%E6%9D%A1%E5%91%BD%E4%BB%A4%E6%B5%81%E7%A8%8B\" style=\"background-color:transparent\">Part2.3. shell\u6267\u884c\u4e00\u6761\u547d\u4ee4\u6d41\u7a0b<\/h3>\n<p>\u4ee5\u6267\u884cls\u4e3e\u4f8b&#xff1a;<\/p>\n<p>1. bash\u521b\u5efa\u5b50\u8fdb\u7a0b&#xff1b;<\/p>\n<p>2. \u5728\u5b50\u8fdb\u7a0b\u5185\u90e8&#xff0c;<span style=\"color:#ed7976\">\u89e3\u6790\u547d\u4ee4&#xff0c;\u5728PATH\u73af\u5883\u53d8\u91cf\u4fdd\u5b58\u7684\u76ee\u5f55\u4f9d\u6b21\u641c\u7d22ls<\/span>&#xff1b;<\/p>\n<p>3. \u627e\u5230\u53ef\u6267\u884c\u6587\u4ef6&#xff0c;<span style=\"color:#98c091\">\u8c03\u7528exec\u6267\u884c\u7a0b\u5e8f<\/span>&#xff1b;<\/p>\n<p>4. \u7a0b\u5e8f\u8fd0\u884c\u7ed3\u675f&#xff0c;\u5b50\u8fdb\u7a0b\u9000\u51fa&#xff0c;<span style=\"color:#6eaad7\">bash\u56de\u6536\u50f5\u5c38\u5b50\u8fdb\u7a0b\u3002<\/span><\/p>\n<hr \/>\n<h2 id=\"Part3.%20%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%E5%9F%BA%E7%A1%80%E6%A6%82%E5%BF%B5\">Part3. \u73af\u5883\u53d8\u91cf\u57fa\u7840\u6982\u5ff5<\/h2>\n<p>\u73af\u5883\u53d8\u91cf\u683c\u5f0f&#xff1a;<span style=\"color:#be191c\">\u540d\u5b57&#061;\u5185\u5bb9<\/span>\u3002 \u2022 <span style=\"color:#be191c\">env<\/span>&#xff1a;\u67e5\u770b\u5168\u90e8\u73af\u5883\u53d8\u91cf&#xff1b;<\/p>\n<p>\u2022 \u73af\u5883\u53d8\u91cf\u5c5e\u4e8e<span style=\"color:#6eaad7\">\u8fdb\u7a0b\u5c5e\u6027<\/span>&#xff0c;<span style=\"color:#ed7976\">\u5b50\u8fdb\u7a0b\u9ed8\u8ba4\u7ee7\u627f\u7236\u8fdb\u7a0b\u5168\u90e8\u73af\u5883\u53d8\u91cf<\/span>\u3002<\/p>\n<hr \/>\n<p>\u5e38\u7528\u73af\u5883\u53d8\u91cf <span style=\"color:#be191c\">echo $HOME<\/span> \u00a0 \u00a0 \u00a0 \u00a0\u5f53\u524d\u7528\u6237\u5bb6\u76ee\u5f55 <span style=\"color:#be191c\">echo $USER \u00a0<\/span> \u00a0 \u00a0 \u00a0\u5f53\u524d\u767b\u5f55\u7528\u6237\u540d <span style=\"color:#be191c\">echo $HISTSIZE<\/span> \u00a0 \u00a0history\u5386\u53f2\u547d\u4ee4\u4fdd\u5b58\u6761\u6570 <span style=\"color:#be191c\">echo $HOSTNAME \u00a0 <\/span>\u00a0\u4e3b\u673a\u540d <span style=\"color:#be191c\">echo $PWD \u00a0<\/span> \u00a0 \u00a0 \u00a0 \u5f53\u524d\u5de5\u4f5c\u76ee\u5f55 <span style=\"color:#be191c\">echo $OLDPWD <\/span>\u00a0 \u00a0 \u00a0\u4e0a\u4e00\u6b21\u7684\u76ee\u5f55&#xff0c;cd &#8211; \u4f9d\u8d56\u8fd9\u4e2a\u53d8\u91cf<\/p>\n<hr \/>\n<p>\u914d\u7f6e\u6587\u4ef6<\/p>\n<p>\u767b\u5f55bash\u65f6&#xff0c;\u4f1a\u8bfb\u53d6\u914d\u7f6e\u6587\u4ef6&#xff1a; <span style=\"color:#be191c\">~\/.bashrc\u3001~\/.bash_profile<\/span>\u3002 \u628a<span style=\"color:#9c8ec1\">\u73af\u5883\u53d8\u91cf\u5199\u8fdb\u8fd9\u4e24\u4e2a\u6587\u4ef6&#xff0c;\u6bcf\u6b21\u6253\u5f00\u7ec8\u7aef\u81ea\u52a8\u751f\u6548<\/span>\u3002<\/p>\n<hr \/>\n<h2 id=\"Part4.%20shell%E6%93%8D%E4%BD%9C%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F\">Part4. shell\u64cd\u4f5c\u73af\u5883\u53d8\u91cf<\/h2>\n<p>1. <span style=\"color:#be191c\">export \u53d8\u91cf\u540d&#061;\u503c<\/span>&#xff1a;\u628a<span style=\"color:#ed7976\">\u672c\u5730\u53d8\u91cf\u5bfc\u51fa\u6210\u73af\u5883\u53d8\u91cf<\/span>&#xff0c;<span style=\"color:#9c8ec1\">\u5b50\u8fdb\u7a0b\u53ef\u4ee5\u7ee7\u627f<\/span>&#xff1b;<\/p>\n<hr \/>\n<p>2.<span style=\"color:#be191c\"> unset \u53d8\u91cf\u540d<\/span>&#xff1a;<span style=\"color:#ed7976\">\u5220\u9664\u73af\u5883\u53d8\u91cf<\/span>&#xff1b;<\/p>\n<hr \/>\n<p>\u533a\u5206\u672c\u5730\u53d8\u91cf\u3001\u73af\u5883\u53d8\u91cf \u2022 \u76f4\u63a5 i&#061;10&#xff0c;\u521b\u5efa\u672c\u5730shell\u53d8\u91cf&#xff0c;\u53ea\u5728<span style=\"color:#ed7976\">\u5f53\u524dbash\u5185\u90e8\u751f\u6548&#xff0c;\u5b50\u8fdb\u7a0b\u62ff\u4e0d\u5230<\/span>&#xff1b;<\/p>\n<\/p>\n<p>\u2022 export i&#061;10&#xff0c;\u53d8\u6210\u73af\u5883\u53d8\u91cf&#xff0c;fork\u51fa\u6765\u7684<span style=\"color:#98c091\">\u5b50\u8fdb\u7a0b\u5168\u90e8\u7ee7\u627f<\/span>\u3002<\/p>\n<\/p>\n<p>\u2022 <span style=\"color:#1c7892\">set\u547d\u4ee4\u53ef\u4ee5\u67e5\u770bshell\u6240\u6709\u672c\u5730\u53d8\u91cf&#043;\u73af\u5883\u53d8\u91cf<\/span>\u3002<\/p>\n<hr \/>\n<h2 id=\"Part5.%20C%E8%AF%AD%E8%A8%80%E6%93%8D%E4%BD%9C%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F\">Part5. C\u8bed\u8a00\u64cd\u4f5c\u73af\u5883\u53d8\u91cf<\/h2>\n<h3 id=\"Part5.1.%20main%E5%87%BD%E6%95%B0%E5%8F%82%E6%95%B0%20envp\" style=\"background-color:transparent\">Part5.1. main\u51fd\u6570\u53c2\u6570 envp<\/h3>\n<p> \/\/ \u7b2c\u4e09\u4e2a\u53c2\u6570\u63a5\u6536\u5168\u90e8\u73af\u5883\u53d8\u91cf<br \/>\nint main(int argc, char *argv[], char *envp[])<br \/>\n{<br \/>\n\u00a0 \u00a0 for(int i &#061; 0; envp[i]; i&#043;&#043;)<br \/>\n\u00a0 \u00a0 {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 printf(&#034;%s\\\\n&#034;, envp[i]);<br \/>\n\u00a0 \u00a0 }<br \/>\n\u00a0 \u00a0 return 0;<br \/>\n} <\/p>\n<p>main\u51fd\u6570\u7b2c\u4e09\u4e2a\u53c2\u6570<span style=\"color:#ed7976\">envp\u63a5\u6536\u8fdb\u7a0b\u5168\u90e8\u73af\u5883\u53d8\u91cf\u6570\u7ec4&#xff0c;\u6570\u7ec4\u672b\u5c3e\u4e3aNULL<\/span>\u3002<\/p>\n<p> <span style=\"color:#1c7892\">\u771f\u6b63\u7a0b\u5e8f\u5165\u53e3\u4e0d\u662fmain&#xff0c;\u662f_start\u51fd\u6570<\/span>&#xff0c;\u7531<span style=\"color:#1c7331\">_start\u628aargc\u3001argv\u3001envp\u4f20\u9012\u7ed9main<\/span>\u3002<\/p>\n<hr \/>\n<h3 id=\"Part5.2.%20getenv%20%E8%8E%B7%E5%8F%96%E6%8C%87%E5%AE%9A%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F\" style=\"background-color:transparent\">Part5.2. getenv \u83b7\u53d6\u6307\u5b9a\u73af\u5883\u53d8\u91cf<\/h3>\n<p> \u5934\u6587\u4ef6&#xff1a;#include &lt;stdlib.h&gt;<br \/>\nchar *value &#061; getenv(&#034;USER&#034;);<br \/>\nif(value &#061;&#061; NULL)<br \/>\n{<br \/>\n\u00a0 \u00a0 \/\/ \u73af\u5883\u53d8\u91cf\u4e0d\u5b58\u5728<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\n\u00a0 \u00a0 printf(&#034;USER&#061;%s\\\\n&#034;, value);<br \/>\n} <\/p>\n<p>\u5e94\u7528\u573a\u666f&#xff1a;<span style=\"color:#b95514\">\u7a0b\u5e8f\u8bfb\u53d6\u73af\u5883\u53d8\u91cf\u505a\u6743\u9650\u5224\u65ad&#xff0c;\u4f8b\u5982\u8bfb\u53d6USER&#xff0c;\u5224\u65ad\u5f53\u524d\u662f\u4ec0\u4e48\u7528\u6237&#xff0c;\u51b3\u5b9a\u7a0b\u5e8f\u662f\u5426\u5141\u8bb8\u8fd0\u884c\u3002<\/span><\/p>\n<hr \/>\n<h3 id=\"Part5.3.%20extern%20environ%20%E5%85%A8%E5%B1%80%E5%8F%98%E9%87%8F\" style=\"background-color:transparent\">Part5.3. extern environ \u5168\u5c40\u53d8\u91cf<\/h3>\n<p> #include &lt;stdio.h&gt;<br \/>\nextern char **environ;<\/p>\n<p>int main()<br \/>\n{<br \/>\n\u00a0 \u00a0 for(int i &#061; 0; environ[i]; i&#043;&#043;)<br \/>\n\u00a0 \u00a0 {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 printf(&#034;%s\\\\n&#034;, environ[i]);<br \/>\n\u00a0 \u00a0 }<br \/>\n\u00a0 \u00a0 return 0;<br \/>\n} <\/p>\n<p><span style=\"color:#1a439c\">environ\u662flibc\u63d0\u4f9b\u7684\u5168\u5c40\u53d8\u91cf&#xff0c;\u4ee3\u8868\u5f53\u524d\u8fdb\u7a0b\u73af\u5883\u53d8\u91cf\u6570\u7ec4<\/span>\u3002<\/p>\n<hr \/>\n<h2 id=\"Part6.%20%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%E7%9A%84%E7%89%B9%E6%80%A7\" style=\"background-color:transparent\">Part6. \u73af\u5883\u53d8\u91cf\u7684\u7279\u6027<\/h2>\n<p>1. \u5168\u5c40&#xff1a;\u7236\u8fdb\u7a0b<span style=\"color:#1c7331\">export\u5bfc\u51fa\u7684\u73af\u5883\u53d8\u91cf&#xff0c;fork\u5b50\u8fdb\u7a0b\u53ef\u4ee5\u7ee7\u627f<\/span>&#xff1b;<\/p>\n<\/p>\n<p>2. \u672c\u5730shell\u53d8\u91cf&#xff0c;\u4ec5\u4ec5<span style=\"color:#1c7892\">\u5f53\u524dshell\u5185\u90e8\u4f7f\u7528&#xff0c;\u5b50\u8fdb\u7a0b\u4e0d\u4f1a\u7ee7\u627f<\/span>&#xff1b;<\/p>\n<\/p>\n<p>3. \u5b50\u8fdb\u7a0b<span style=\"color:#1a439c\">\u4fee\u6539\u7ee7\u627f\u8fc7\u6765\u7684\u73af\u5883\u53d8\u91cf&#xff0c;\u4e0d\u4f1a\u5f71\u54cd\u7236\u8fdb\u7a0b&#xff0c;\u73af\u5883\u53d8\u91cf\u968f\u8fdb\u7a0b\u5730\u5740\u7a7a\u95f4\u62f7\u8d1d<\/span>\u3002<\/p>\n<hr \/>\n<h2 id=\"Part7.%20shell%E8%84%9A%E6%9C%AC\" style=\"background-color:transparent\">Part7. shell\u811a\u672c<\/h2>\n<p> <span style=\"color:#494949\">\u811a\u672c\u6587\u4ef6\u5f00\u5934\u5fc5\u987b\u6307\u5b9a\u89e3\u91ca\u5668&#xff1a;<\/span><\/p>\n<p> <span style=\"color:#be191c\">!\/bin\/bash<\/span><\/p>\n<p> <span style=\"color:#494949\">\u540e\u9762\u5199shell\u547d\u4ee4 \u6267\u884c\u811a\u672c&#xff1a;<\/span><br \/>\n <span style=\"color:#be191c\">bash 1.sh\u6216\u8005.\/1.sh<\/span><br \/>\n <span style=\"color:#494949\">\u3002<\/span><\/p>\n<hr \/>\n<h2 id=\"Part8.%20%E8%BF%9B%E7%A8%8B%E5%9C%B0%E5%9D%80%E7%A9%BA%E9%97%B4%E8%A1%A5%E5%85%85\" style=\"background-color:transparent\"><span style=\"color:#494949\">Part8. \u8fdb\u7a0b\u5730\u5740\u7a7a\u95f4\u8865\u5145<\/span><\/h2>\n<p> <span style=\"color:#494949\">\u73af\u5883\u53d8\u91cf<\/span><span style=\"color:#ed7976\">\u5b58\u653e\u5728\u8fdb\u7a0b\u865a\u62df\u5730\u5740\u7a7a\u95f4&#xff0c;\u4e0d\u662f\u7269\u7406\u5185\u5b58<\/span><\/p>\n<p> <span style=\"color:#494949\">fork\u4e4b\u540e<\/span><span style=\"color:#1c7331\">\u5b50\u8fdb\u7a0b\u62ff\u5230\u4e00\u4efd\u62f7\u8d1d&#xff0c;\u7236\u5b50\u865a\u62df\u5730\u5740\u76f8\u540c&#xff0c;\u4f46\u662f\u7269\u7406\u5185\u5b58\u4e0d\u540c&#xff0c;\u4fee\u6539\u4e92\u4e0d\u5e72\u6270<\/span><span style=\"color:#494949\">\u3002<\/span><\/p>\n<p> <span style=\"color:#494949\">\u7236\u8fdb\u7a0b\u5168\u5c40\u53d8\u91cf&#xff0c;fork\u4e4b\u540e\u7236\u5b50\u865a\u62df\u5730\u5740\u4e00\u6837&#xff0c;\u4f46\u662f\u7269\u7406\u5185\u5b58\u4e0d\u540c&#xff0c;<\/span><span style=\"color:#1a439c\">\u5b50\u8fdb\u7a0b\u4fee\u6539\u4e0d\u4f1a\u5f71\u54cd\u7236\u8fdb\u7a0b\u3002<\/span><\/p>\n<hr \/>\n<h2 id=\"Part9.%20%E7%BB%93%E8%AF%AD\" style=\"background-color:transparent\">Part9. \u7ed3\u8bed<\/h2>\n<p> <span style=\"color:#494949\">\u00a0\u8fd9\u7bc7\u6587\u7ae0\u6211\u4eec\u8ba4\u8bc6\u5e76\u77e5\u9053\u4e86Linux\u73af\u5883\u53d8\u91cf\u7684\u4f7f\u7528&#xff0c;\u63a5\u4e0b\u6765&#xff0c;\u5c0f\u7f16\u8fd8\u4f1a\u5e26\u6765\u66f4\u591aLinux\u76f8\u5173\u7684\u77e5\u8bc6&#xff0c;\u656c\u8bf7\u671f\u5f85~<\/span><\/p>\n<p>\u00a0\u6700\u540e&#xff0c;\u795d\u5927\u5bb6\u53ef\u4ee5&#xff1a;<span style=\"color:#fe2c24\">\u6625\u98ce\u5f97\u610f\u9a6c\u8e44\u75be&#xff0c;\u4e00\u65e5\u770b\u5c3d\u957f\u5b89\u82b1&#xff01;<\/span><\/p>\n<p>\u00a0\u6700\u540e\u7684\u6700\u540e&#xff0c;\u8981\u662f\u89c9\u5f97\u672c\u6587\u8fd8\u53ef\u4ee5\u7684\u8bdd&#xff0c;\u53ef\u4ee5\u70b9\u70b9\u8d5e&#xff0c;\u5173\u6ce8\u5c0f\u7f16\u4e00\u6ce2&#xff0c;<span style=\"color:#fe2c24\">\u8c22\u8c22\u5927\u5bb6&#xff01;~<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u5f55<br \/>\n\u524d\u8a00<br \/>\nPart1. main\u51fd\u6570\u547d\u4ee4\u884c\u53c2\u6570<br \/>\nPart2. PATH\u73af\u5883\u53d8\u91cf<br \/>\nPart2.1. PATH\u4f5c\u7528<br \/>\nPart2.2. \u67e5\u770bPATH<br \/>\nPart2.3. shell\u6267\u884c\u4e00\u6761\u547d\u4ee4\u6d41\u7a0b<br \/>\nPart3. \u73af\u5883\u53d8\u91cf\u57fa\u7840\u6982\u5ff5<br \/>\nPart4. shell\u64cd\u4f5c\u73af\u5883\u53d8\u91cf<br \/>\nPart5. C\u8bed\u8a00\u64cd\u4f5c\u73af\u5883\u53d8\u91cf<br \/>\nPart5.1. main\u51fd\u6570\u53c2\u6570 envp<br \/>\nPart5.2. getenv \u83b7\u53d6\u6307\u5b9a\u73af\u5883\u53d8\u91cf<br \/>\nPart5.3. extern environ \u5168\u5c40\u53d8\u91cf<br \/>\nPa<\/p>\n","protected":false},"author":2,"featured_media":102215,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[11675,58],"topic":[],"class_list":["post-102216","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-11675","tag-linux"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010\u77e5\u8bc6\u8bb2\u89e3\u3011 Linux\u73af\u5883\u53d8\u91cf\u7684\u8ba4\u8bc6\u4e0e\u4f7f\u7528 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/102216.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010\u77e5\u8bc6\u8bb2\u89e3\u3011 Linux\u73af\u5883\u53d8\u91cf\u7684\u8ba4\u8bc6\u4e0e\u4f7f\u7528 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u76ee\u5f55 \u524d\u8a00 Part1. main\u51fd\u6570\u547d\u4ee4\u884c\u53c2\u6570 Part2. PATH\u73af\u5883\u53d8\u91cf Part2.1. PATH\u4f5c\u7528 Part2.2. \u67e5\u770bPATH Part2.3. shell\u6267\u884c\u4e00\u6761\u547d\u4ee4\u6d41\u7a0b Part3. \u73af\u5883\u53d8\u91cf\u57fa\u7840\u6982\u5ff5 Part4. shell\u64cd\u4f5c\u73af\u5883\u53d8\u91cf Part5. C\u8bed\u8a00\u64cd\u4f5c\u73af\u5883\u53d8\u91cf Part5.1. main\u51fd\u6570\u53c2\u6570 envp Part5.2. getenv \u83b7\u53d6\u6307\u5b9a\u73af\u5883\u53d8\u91cf Part5.3. extern environ \u5168\u5c40\u53d8\u91cf Pa\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/102216.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-08T03:12:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260908031241-6a9f7d290cf18.jpg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/102216.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/102216.html\",\"name\":\"\u3010\u77e5\u8bc6\u8bb2\u89e3\u3011 Linux\u73af\u5883\u53d8\u91cf\u7684\u8ba4\u8bc6\u4e0e\u4f7f\u7528 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-08T03:12:44+00:00\",\"dateModified\":\"2026-09-08T03:12:44+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/102216.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/102216.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/102216.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010\u77e5\u8bc6\u8bb2\u89e3\u3011 Linux\u73af\u5883\u53d8\u91cf\u7684\u8ba4\u8bc6\u4e0e\u4f7f\u7528\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u3010\u77e5\u8bc6\u8bb2\u89e3\u3011 Linux\u73af\u5883\u53d8\u91cf\u7684\u8ba4\u8bc6\u4e0e\u4f7f\u7528 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/102216.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010\u77e5\u8bc6\u8bb2\u89e3\u3011 Linux\u73af\u5883\u53d8\u91cf\u7684\u8ba4\u8bc6\u4e0e\u4f7f\u7528 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u76ee\u5f55 \u524d\u8a00 Part1. main\u51fd\u6570\u547d\u4ee4\u884c\u53c2\u6570 Part2. PATH\u73af\u5883\u53d8\u91cf Part2.1. PATH\u4f5c\u7528 Part2.2. \u67e5\u770bPATH Part2.3. shell\u6267\u884c\u4e00\u6761\u547d\u4ee4\u6d41\u7a0b Part3. \u73af\u5883\u53d8\u91cf\u57fa\u7840\u6982\u5ff5 Part4. shell\u64cd\u4f5c\u73af\u5883\u53d8\u91cf Part5. C\u8bed\u8a00\u64cd\u4f5c\u73af\u5883\u53d8\u91cf Part5.1. main\u51fd\u6570\u53c2\u6570 envp Part5.2. getenv \u83b7\u53d6\u6307\u5b9a\u73af\u5883\u53d8\u91cf Part5.3. extern environ \u5168\u5c40\u53d8\u91cf Pa","og_url":"https:\/\/www.wsisp.com\/helps\/102216.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-08T03:12:44+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260908031241-6a9f7d290cf18.jpg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/102216.html","url":"https:\/\/www.wsisp.com\/helps\/102216.html","name":"\u3010\u77e5\u8bc6\u8bb2\u89e3\u3011 Linux\u73af\u5883\u53d8\u91cf\u7684\u8ba4\u8bc6\u4e0e\u4f7f\u7528 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-08T03:12:44+00:00","dateModified":"2026-09-08T03:12:44+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/102216.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/102216.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/102216.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010\u77e5\u8bc6\u8bb2\u89e3\u3011 Linux\u73af\u5883\u53d8\u91cf\u7684\u8ba4\u8bc6\u4e0e\u4f7f\u7528"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/102216","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=102216"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/102216\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/102215"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=102216"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=102216"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=102216"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=102216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}