{"id":14357,"date":"2025-04-18T21:08:31","date_gmt":"2025-04-18T13:08:31","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/14357.html"},"modified":"2025-04-18T21:08:31","modified_gmt":"2025-04-18T13:08:31","slug":"%e4%bc%98%e5%85%88%e7%ba%a7%e4%b8%8e%e7%8e%af%e5%a2%83%e5%8f%98%e9%87%8f%e7%9a%84%e8%89%ba%e6%9c%af%ef%bc%9a%e9%a9%be%e9%a9%ad-linux-%e7%b3%bb%e7%bb%9f%e7%9a%84%e6%a0%b8%e5%bf%83","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/14357.html","title":{"rendered":"\u4f18\u5148\u7ea7\u4e0e\u73af\u5883\u53d8\u91cf\u7684\u827a\u672f\uff1a\u9a7e\u9a6d Linux \u7cfb\u7edf\u7684\u6838\u5fc3"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418130827-68024ecb1f59a.gif\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<\/p>\n<h4>\u6587\u7ae0\u76ee\u5f55<\/h4>\n<ul>\n<li>\u524d\u8a00<\/li>\n<li>\n<ul>\n<li>\u4e00\u3001\u4ec0\u4e48\u662f\u8fdb\u7a0b\u4f18\u5148\u7ea7&#xff1f;<\/li>\n<li>\u4e8c\u3001Linux \u7cfb\u7edf\u4e2d\u7684\u4f18\u5148\u7ea7<\/li>\n<li>\n<ul>\n<li>2.1 \u67e5\u770b\u8fdb\u7a0b\u4f18\u5148\u7ea7<\/li>\n<li>2.2 PRI \u548c NI \u7684\u5173\u7cfb<\/li>\n<li>2.3 \u4fee\u6539\u8fdb\u7a0b\u4f18\u5148\u7ea7<\/li>\n<li>2.4 \u8fdb\u7a0b\u4f18\u5148\u7ea7\u7684\u5b9e\u73b0\u539f\u7406<\/li>\n<li>2.5 \u8fdb\u7a0b\u7684\u7279\u6027<\/li>\n<\/ul>\n<\/li>\n<li>\u4e09\u3001\u73af\u5883\u53d8\u91cf<\/li>\n<li>\n<ul>\n<li>3.1 PATH\u2014\u2014\u641c\u7d22\u53ef\u6267\u884c\u6587\u4ef6\u7684\u76ee\u5f55\u5217\u8868<\/li>\n<li>\n<ul>\n<li>1. \u4e3a\u4ec0\u4e48\u81ea\u5df1\u5199\u7684\u7a0b\u5e8f\u9700\u8981\u52a0 &#096;.\/&#096; \u624d\u80fd\u6267\u884c&#xff1f;<\/li>\n<li>2. \u4e3a\u4ec0\u4e48\u6267\u884c\u6307\u4ee4\u65f6\u4e0d\u9700\u8981\u52a0\u8def\u5f84&#xff1f;<\/li>\n<li>3. \u5982\u4f55\u67e5\u770b\u548c\u4fee\u6539 &#096;PATH&#096;&#xff1f;<\/li>\n<\/ul>\n<\/li>\n<li>3.2 HOME\u2014\u2014\u8868\u793a\u5f53\u524d\u7528\u6237\u7684\u4e3b\u76ee\u5f55\u8def\u5f84<\/li>\n<li>\n<ul>\n<li>1. \u4ec0\u4e48\u662f &#096;HOME&#096;&#xff1f;<\/li>\n<li>2. \u4f5c\u4e3a\u9ed8\u8ba4\u5de5\u4f5c\u76ee\u5f55<\/li>\n<li>3. \u67e5\u770b &#096;HOME&#096; \u73af\u5883\u53d8\u91cf\u7684\u503c<\/li>\n<\/ul>\n<\/li>\n<li>3.3 USER\u2014\u2014\u5b58\u50a8\u5f53\u524d\u767b\u5f55\u7528\u6237\u7684\u7528\u6237\u540d<\/li>\n<li>\n<ul>\n<li>1. \u793a\u4f8b\u4ee3\u7801 1&#xff1a;\u6253\u5370\u5f53\u524d\u7528\u6237<\/li>\n<li>2. \u793a\u4f8b\u4ee3\u7801 2&#xff1a;\u5224\u65ad\u7528\u6237\u6743\u9650<\/li>\n<li>3. USER \u4e0e\u6743\u9650\u8ba4\u8bc1<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u56db\u3001\u547d\u4ee4\u884c\u53c2\u6570<\/li>\n<li>\n<ul>\n<li>4.1 \u4ec0\u4e48\u662f\u547d\u4ee4\u884c\u53c2\u6570&#xff1f;<\/li>\n<li>4.2 main \u51fd\u6570\u7684\u5f62\u5f0f<\/li>\n<li>4.3 \u547d\u4ee4\u884c\u53c2\u6570\u7684\u4f5c\u7528<\/li>\n<li>4.4 main\u51fd\u6570\u7684\u7b2c\u4e09\u4e2a\u53c2\u6570<\/li>\n<li>4.5 \u73af\u5883\u53d8\u91cf\u7684\u7ee7\u627f<\/li>\n<li>\n<ul>\n<li>\u9a8c\u8bc1\u5b50\u8fdb\u7a0b\u7ee7\u627f\u73af\u5883\u53d8\u91cf<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u4e94\u3001\u672c\u5730\u53d8\u91cf\u4e0e\u5185\u5efa\u547d\u4ee4<\/li>\n<li>\n<ul>\n<li>5.1 \u4e3a\u4ec0\u4e48 &#096;echo&#096; \u80fd\u6253\u5370\u672c\u5730\u53d8\u91cf<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u7ed3\u8bed<\/li>\n<\/ul>\n<hr \/>\n<h2>\u524d\u8a00<\/h2>\n<p>\u5728 Linux \u7cfb\u7edf\u4e2d&#xff0c;\u8fdb\u7a0b\u548c\u73af\u5883\u53d8\u91cf\u662f\u64cd\u4f5c\u7cfb\u7edf\u7684\u6838\u5fc3\u7ec4\u6210\u90e8\u5206\u3002\u8fdb\u7a0b\u4f18\u5148\u7ea7\u51b3\u5b9a\u4e86\u8d44\u6e90\u5206\u914d\u7684\u5148\u540e\u987a\u5e8f&#xff0c;\u76f4\u63a5\u5f71\u54cd\u7cfb\u7edf\u6027\u80fd&#xff1b;\u800c\u73af\u5883\u53d8\u91cf\u5219\u63d0\u4f9b\u4e86\u4e00\u79cd\u7075\u6d3b\u7684\u65b9\u5f0f&#xff0c;\u7528\u4e8e\u4f20\u9012\u7cfb\u7edf\u914d\u7f6e\u4fe1\u606f\u4ee5\u53ca\u63a7\u5236\u7a0b\u5e8f\u7684\u8fd0\u884c\u73af\u5883\u3002\u672c\u7bc7\u6587\u7ae0\u5c06\u6df1\u5165\u63a2\u8ba8\u8fdb\u7a0b\u4f18\u5148\u7ea7\u7684\u6982\u5ff5\u3001\u8c03\u8282\u65b9\u6cd5\u53ca\u5176\u539f\u7406&#xff0c;\u4ee5\u53ca\u73af\u5883\u53d8\u91cf\u7684\u5b9a\u4e49\u3001\u7279\u6027\u548c\u5b9e\u9645\u5e94\u7528&#xff0c;\u5e2e\u52a9\u8bfb\u8005\u66f4\u597d\u5730\u7406\u89e3 Linux \u7cfb\u7edf\u7684\u6838\u5fc3\u673a\u5236&#xff0c;\u4ece\u800c\u5728\u5b9e\u9645\u5de5\u4f5c\u4e2d\u66f4\u9ad8\u6548\u5730\u8c03\u8bd5\u548c\u4f18\u5316\u7cfb\u7edf\u3002<\/p>\n<hr \/>\n<h3>\u4e00\u3001\u4ec0\u4e48\u662f\u8fdb\u7a0b\u4f18\u5148\u7ea7&#xff1f;<\/h3>\n<li>\u4f18\u5148\u7ea7\u7684\u5b9a\u4e49&#xff1a;\n<ul>\n<li>\u4f18\u5148\u7ea7\u51b3\u5b9a\u4e86\u591a\u4e2a\u8fdb\u7a0b\u7ade\u4e89 CPU \u65f6&#xff0c;\u54ea\u4e2a\u8fdb\u7a0b\u4f18\u5148\u83b7\u5f97 CPU \u65f6\u95f4\u7247\u3002<\/li>\n<li>\u533a\u522b\u4e8e\u6743\u9650&#xff0c;\u6743\u9650\u51b3\u5b9a\u80fd\u4e0d\u80fd\u6267\u884c\u67d0\u4e2a\u4efb\u52a1&#xff0c;\u800c\u4f18\u5148\u7ea7\u51b3\u5b9a\u8c01\u5148\u6267\u884c\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u4f18\u5148\u7ea7\u7684\u4f5c\u7528&#xff1a;\n<ul>\n<li>\u901a\u8fc7\u4f18\u5148\u7ea7\u673a\u5236&#xff0c;\u64cd\u4f5c\u7cfb\u7edf\u80fd\u591f\u516c\u5e73\u5730\u5206\u914d CPU \u8d44\u6e90&#xff0c;\u9632\u6b62\u67d0\u4e9b\u8fdb\u7a0b\u957f\u671f\u5f97\u4e0d\u5230 CPU \u7684\u95ee\u9898&#xff08;\u5373\u8fdb\u7a0b\u9965\u997f\u95ee\u9898&#xff09;\u3002<\/li>\n<li>\u4f8b\u5982&#xff1a;\n<ul>\n<li>\u9ad8\u4f18\u5148\u7ea7\u8fdb\u7a0b&#xff08;\u5b9e\u65f6\u4efb\u52a1&#xff09;\u53ef\u4ee5\u66f4\u5feb\u5730\u6267\u884c\u3002<\/li>\n<li>\u4f4e\u4f18\u5148\u7ea7\u8fdb\u7a0b\u53ef\u80fd\u88ab\u63a8\u8fdf&#xff0c;\u4f46\u4e0d\u4f1a\u88ab\u997f\u6b7b&#xff08;\u901a\u8fc7\u8c03\u5ea6\u7b97\u6cd5\u4fdd\u8bc1&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u5c0f\u7ed3&#xff1a;\n<ul>\n<li>CPU \u8d44\u6e90\u5206\u914d\u7684\u5148\u540e\u987a\u5e8f\u7531\u4f18\u5148\u7ea7\u51b3\u5b9a\u3002<\/li>\n<li>Linux \u7684\u8c03\u5ea6\u5668\u6839\u636e\u4f18\u5148\u7ea7\u52a8\u6001\u8c03\u5ea6\u8fdb\u7a0b&#xff0c;\u63d0\u9ad8\u7cfb\u7edf\u7684\u6574\u4f53\u6027\u80fd\u3002<\/li>\n<\/ul>\n<\/li>\n<h3>\u4e8c\u3001Linux \u7cfb\u7edf\u4e2d\u7684\u4f18\u5148\u7ea7<\/h3>\n<h4>2.1 \u67e5\u770b\u8fdb\u7a0b\u4f18\u5148\u7ea7<\/h4>\n<p>\u793a\u4f8b\u4ee3\u7801&#xff1a;<\/p>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;stdio.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;unistd.h&gt;<\/span><\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">while<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;I am a process, PID:%d, PPID:%d\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token function\">getpid<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token function\">getppid<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token function\">sleep<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u8fd0\u884c\u6b65\u9aa4&#xff1a;<\/p>\n<li>\n<p>\u7f16\u8bd1\u8fd0\u884c\u7a0b\u5e8f&#xff1a;<\/p>\n<p> gcc process.c <span class=\"token parameter variable\">-o<\/span> process<br \/>\n.\/process\n <\/li>\n<li>\n<p>\u6253\u5f00\u53e6\u4e00\u4e2a\u7ec8\u7aef&#xff0c;\u67e5\u770b\u8fdb\u7a0b\u7684\u4f18\u5148\u7ea7&#xff1a;<\/p>\n<p> <span class=\"token function\">ps<\/span> <span class=\"token parameter variable\">-al<\/span> <span class=\"token operator\">|<\/span> <span class=\"token function\">head<\/span> <span class=\"token parameter variable\">-1<\/span> <span class=\"token punctuation\">;<\/span> <span class=\"token function\">ps<\/span> <span class=\"token parameter variable\">-al<\/span> <span class=\"token operator\">|<\/span> <span class=\"token function\">grep<\/span> process\n <\/li>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418130827-68024ecb37830.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> \u8f93\u51fa\u5b57\u6bb5\u89e3\u6790&#xff1a;<\/p>\n<ul>\n<li>UID&#xff1a;\u8868\u793a\u8fdb\u7a0b\u7684\u6267\u884c\u8005\u8eab\u4efd\u3002<\/li>\n<li>PID&#xff1a;\u5f53\u524d\u8fdb\u7a0b\u7684 ID\u3002<\/li>\n<li>PPID&#xff1a;\u5f53\u524d\u8fdb\u7a0b\u7684\u7236\u8fdb\u7a0b ID\u3002<\/li>\n<li>PRI&#xff1a;\u8fdb\u7a0b\u7684\u4f18\u5148\u7ea7\u503c&#xff0c;\u503c\u8d8a\u5c0f\u4f18\u5148\u7ea7\u8d8a\u9ad8\u3002<\/li>\n<li>NI&#xff1a;\u8fdb\u7a0b\u7684 nice \u503c&#xff0c;\u8c03\u6574\u4f18\u5148\u7ea7\u7684\u4fee\u6b63\u503c\u3002<\/li>\n<\/ul>\n<h4>2.2 PRI \u548c NI \u7684\u5173\u7cfb<\/h4>\n<li>\n<p>PRI&#xff08;Priority&#xff09;&#xff1a;<\/p>\n<ul>\n<li>\u8868\u793a\u8fdb\u7a0b\u7684\u5b9e\u9645\u4f18\u5148\u7ea7&#xff0c;\u503c\u8d8a\u5c0f\u4f18\u5148\u7ea7\u8d8a\u9ad8\u3002<\/li>\n<li>Linux \u8c03\u5ea6\u5668\u6839\u636e PRI \u503c\u51b3\u5b9a\u54ea\u4e2a\u8fdb\u7a0b\u4f18\u5148\u6267\u884c\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>NI&#xff08;Nice \u503c&#xff09;&#xff1a;<\/p>\n<ul>\n<li>\u662f\u8fdb\u7a0b\u4f18\u5148\u7ea7\u7684\u4fee\u6b63\u503c&#xff0c;\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u8c03\u6574 nice \u503c\u6765\u5f71\u54cd PRI \u503c\u3002<\/li>\n<li>nice \u503c\u8303\u56f4&#xff1a;\n<ul>\n<li>[-20, 19]&#xff0c;\u5171 40 \u4e2a\u7ea7\u522b\u3002<\/li>\n<li>\u9ed8\u8ba4\u503c\u662f 0\u3002<\/li>\n<\/ul>\n<\/li>\n<li>nice \u503c\u7684\u5f71\u54cd&#xff1a;\n<ul>\n<li>\u8d1f\u6570&#xff1a;\u63d0\u9ad8\u4f18\u5148\u7ea7&#xff08;PRI \u503c\u51cf\u5c0f&#xff09;\u3002<\/li>\n<li>\u6b63\u6570&#xff1a;\u964d\u4f4e\u4f18\u5148\u7ea7&#xff08;PRI \u503c\u589e\u5927&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u5173\u7cfb\u516c\u5f0f&#xff1a;<\/p>\n<p> PRI(new) &#061; PRI(old) &#043; nice<\/p>\n<ul>\n<li>PRI(old)&#xff1a;\u7cfb\u7edf\u9ed8\u8ba4\u4f18\u5148\u7ea7&#xff0c;\u8d77\u59cb\u503c\u4e3a 80\u3002<\/li>\n<li>nice \u503c&#xff1a;\u7528\u6237\u8bbe\u7f6e\u7684\u8c03\u6574\u503c\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4e3e\u4f8b&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b&#xff08;nice&#061;0&#xff09;&#xff0c;PRI \u503c\u4e3a 80\u3002<\/p>\n<\/li>\n<li>\n<p>\u5982\u679c nice&#061;-10&#xff0c;\u5219&#xff1a;<\/p>\n<p> PRI &#061; 80 &#043; (-10) &#061; 70  &#xff08;\u4f18\u5148\u7ea7\u63d0\u9ad8&#xff09;\n <\/li>\n<\/ul>\n<\/li>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418130827-68024ecb4bbdd.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h4>2.3 \u4fee\u6539\u8fdb\u7a0b\u4f18\u5148\u7ea7<\/h4>\n<li>\n<p>\u67e5\u770b\u8fdb\u7a0b\u4f18\u5148\u7ea7&#xff08;top \u547d\u4ee4&#xff09;&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u4f7f\u7528 top \u5b9e\u65f6\u76d1\u63a7\u7cfb\u7edf\u8fdb\u7a0b&#xff1a;<\/p>\n<p> <span class=\"token function\">top<\/span>\n <\/li>\n<li>\n<p>\u627e\u5230\u76ee\u6807\u8fdb\u7a0b\u7684 PID\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4fee\u6539\u4f18\u5148\u7ea7&#xff1a;<\/p>\n<ul>\n<li>\u5728 top \u4e2d&#xff0c;\u6309\u4e0b r \u952e\u3002<\/li>\n<li>\u8f93\u5165\u76ee\u6807\u8fdb\u7a0b\u7684 PID\u3002<\/li>\n<li>\u8f93\u5165\u65b0\u7684 nice \u503c&#xff08;\u8303\u56f4&#xff1a;-20 \u81f3 19&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u547d\u4ee4\u884c\u65b9\u5f0f\u4fee\u6539&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u542f\u52a8\u65b0\u8fdb\u7a0b\u5e76\u8bbe\u7f6e nice \u503c&#xff1a;<\/p>\n<p> <span class=\"token function\">nice<\/span> <span class=\"token parameter variable\">-n<\/span> <span class=\"token operator\">&lt;<\/span>nice\u503c<span class=\"token operator\">&gt;<\/span> .\/process<\/p>\n<p>\u793a\u4f8b&#xff1a;<\/p>\n<p> <span class=\"token function\">nice<\/span> <span class=\"token parameter variable\">-n<\/span> <span class=\"token parameter variable\">-10<\/span> .\/process\n <\/li>\n<li>\n<p>\u8c03\u6574\u8fd0\u884c\u4e2d\u7684\u8fdb\u7a0b&#xff1a;<\/p>\n<p> <span class=\"token function\">renice<\/span> <span class=\"token operator\">&lt;<\/span>nice\u503c<span class=\"token operator\">&gt;<\/span> <span class=\"token parameter variable\">-p<\/span> <span class=\"token operator\">&lt;<\/span>PID<span class=\"token operator\">&gt;<\/span><\/p>\n<p>\u793a\u4f8b&#xff1a;<\/p>\n<p> <span class=\"token function\">renice<\/span> <span class=\"token parameter variable\">-5<\/span> <span class=\"token parameter variable\">-p<\/span> <span class=\"token number\">12345<\/span>\n <\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u6ce8\u610f&#xff1a;<\/p>\n<ul>\n<li>\u53ea\u6709 root \u7528\u6237 \u53ef\u4ee5\u8bbe\u7f6e\u8d1f\u7684 nice \u503c&#xff08;\u63d0\u9ad8\u4f18\u5148\u7ea7&#xff09;\u3002<\/li>\n<li>\u666e\u901a\u7528\u6237\u53ea\u80fd\u964d\u4f4e\u4f18\u5148\u7ea7\u3002<\/li>\n<\/ul>\n<\/li>\n<h4>2.4 \u8fdb\u7a0b\u4f18\u5148\u7ea7\u7684\u5b9e\u73b0\u539f\u7406<\/h4>\n<li>\u8fdb\u7a0b\u63a7\u5236\u5757&#xff08;PCB&#xff09;&#xff1a;\n<ul>\n<li>\u6bcf\u4e2a\u8fdb\u7a0b\u5728\u5185\u6838\u4e2d\u5bf9\u5e94\u4e00\u4e2a task_struct \u7ed3\u6784\u4f53&#xff08;\u5373\u8fdb\u7a0b\u63a7\u5236\u5757&#xff09;\u3002<\/li>\n<li>task_struct \u4e2d\u5305\u542b\u8fdb\u7a0b\u7684\u4f18\u5148\u7ea7\u3001\u72b6\u6001\u7b49\u4fe1\u606f\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u4f18\u5148\u7ea7\u961f\u5217&#xff1a;\n<ul>\n<li>\u7cfb\u7edf\u6839\u636e\u8fdb\u7a0b\u7684 PRI \u503c\u5c06\u5176\u52a0\u5165\u5bf9\u5e94\u7684\u4f18\u5148\u7ea7\u961f\u5217\u3002<\/li>\n<li>\u4fee\u6539\u4f18\u5148\u7ea7\u7684\u672c\u8d28&#xff1a;\n<ul>\n<li>\u5f53\u8c03\u6574\u8fdb\u7a0b\u7684 nice \u503c\u65f6&#xff0c;\u5185\u6838\u4f1a\u5c06\u8be5\u8fdb\u7a0b\u4ece\u5f53\u524d\u961f\u5217\u79fb\u51fa&#xff0c;\u5e76\u91cd\u65b0\u52a0\u5165\u65b0\u7684\u4f18\u5148\u7ea7\u961f\u5217\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<h4>2.5 \u8fdb\u7a0b\u7684\u7279\u6027<\/h4>\n<ul>\n<li>\n<p>\u7ade\u4e89\u6027&#xff1a;\u7cfb\u7edf\u8fdb\u7a0b\u6570\u76ee\u4f17\u591a&#xff0c;\u800c CPU \u8d44\u6e90\u53ea\u6709\u5c11\u91cf&#xff0c;\u751a\u81f31\u4e2a&#xff0c;\u6240\u4ee5\u8fdb\u7a0b\u4e4b\u95f4\u662f\u5177\u6709\u7ade\u4e89\u5c5e\u6027\u7684\u3002\u4e3a\u4e86\u9ad8\u6548\u5b8c\u6210\u4efb\u52a1&#xff0c;\u66f4\u5408\u7406\u7ade\u4e89\u76f8\u5173\u8d44\u6e90&#xff0c;\u4fbf\u5177\u6709\u4e86\u4f18\u5148\u7ea7\u3002<\/p>\n<\/li>\n<li>\n<p>\u72ec\u7acb\u6027&#xff1a;\u591a\u8fdb\u7a0b\u8fd0\u884c&#xff0c;\u9700\u8981\u72ec\u4eab\u5404\u79cd\u8d44\u6e90&#xff0c;\u591a\u8fdb\u7a0b\u8fd0\u884c\u671f\u95f4\u4e92\u4e0d\u5e72\u6270\u3002<\/p>\n<\/li>\n<li>\n<p>\u5e76\u884c&#xff1a;\u591a\u4e2a\u8fdb\u7a0b\u5728\u591a\u4e2a CPU \u4e0b\u5206\u522b\u540c\u65f6\u8fd0\u884c&#xff0c;\u8fd9\u79f0\u4e4b\u4e3a\u5e76\u884c\u3002<\/p>\n<\/li>\n<li>\n<p>\u5e76\u53d1&#xff1a;\u591a\u4e2a\u8fdb\u7a0b\u5728\u4e00\u4e2a CPU \u4e0b\u91c7\u7528\u8fdb\u7a0b\u5207\u6362\u7684\u65b9\u5f0f&#xff0c;\u5728\u4e00\u6bb5\u65f6\u95f4\u4e4b\u5185&#xff0c;\u8ba9\u591a\u4e2a\u8fdb\u7a0b\u90fd\u5f97\u4ee5\u63a8\u8fdb&#xff0c;\u79f0\u4e4b\u4e3a\u5e76\u53d1\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u5e76\u53d1\u60c5\u51b5\u4e0b&#xff0c; \u64cd\u4f5c\u7cfb\u7edf\u4f1a\u6839\u636e\u6bcf\u4e2a\u8fdb\u7a0b\u7684\u65f6\u95f4\u7247\u8fdb\u884c\u8fdb\u7a0b\u95f4\u7684\u5207\u6362&#xff0c;\u53ea\u8981\u5f53\u524d\u6b63\u5728\u88ab CPU \u8c03\u5ea6\u7684\u8fdb\u7a0b\u7684\u65f6\u95f4\u7247\u5230\u4e86&#xff0c;\u65e0\u8bba\u6709\u6ca1\u6709\u6267\u884c\u7ed3\u675f&#xff0c;\u90fd\u4f1a\u88ab\u64cd\u4f5c\u7cfb\u7edf\u4ece CPU \u4e0a\u62ff\u4e0b\u6765&#xff0c;\u653e\u5230 waiting \u6570\u7ec4\u4e2d\u53bb\u6392\u961f&#xff0c;\u7b49\u5f85 CPU \u7684\u4e0b\u4e00\u6b21\u8c03\u5ea6&#xff0c;\u6211\u4eec\u628a\u8fd9\u79cd\u8fc7\u7a0b\u53eb\u505a\u8fdb\u7a0b\u57fa\u4e8e\u65f6\u95f4\u7247\u8f6e\u8f6c\u7684\u8c03\u5ea6\u7b97\u6cd5\u3002<\/p>\n<p>\u4e24\u4e2a\u95ee\u9898&#xff1a;<\/p>\n<p>1.\u4e3a\u4ec0\u4e48\u51fd\u6570\u8fd4\u56de\u503c&#xff0c;\u4f1a\u88ab\u5916\u90e8\u62ff\u5230\u5462&#xff1f;<\/p>\n<p>\u51fd\u6570\u8c03\u7528\u8fc7\u7a0b\u4e2d&#xff0c;\u6808\u4f1a\u4fdd\u5b58\u5fc5\u8981\u7684\u4fe1\u606f&#xff0c;\u5305\u62ec\u8fd4\u56de\u5730\u5740\u3001\u53c2\u6570\u548c\u5c40\u90e8\u53d8\u91cf\u7b49\u3002<\/p>\n<p>\u8fd4\u56de\u503c\u901a\u8fc7\u5bc4\u5b58\u5668\u6216\u6808\u4e0a\u7684\u7279\u5b9a\u4f4d\u7f6e\u4f20\u9012\u7ed9\u8c03\u7528\u8005&#xff1a;<\/p>\n<ul>\n<li>\u5982\u679c\u8fd4\u56de\u503c\u662f\u901a\u8fc7\u6808\u8fd4\u56de&#xff0c;\u8c03\u7528\u8005\u4f1a\u5728\u6808\u4e0a\u9884\u7559\u4e00\u5757\u533a\u57df&#xff0c;\u51fd\u6570\u76f4\u63a5\u5c06\u8fd4\u56de\u503c\u5199\u5165\u8fd9\u5757\u533a\u57df\u3002<\/li>\n<li>\u5728\u8c03\u7528\u5b8c\u6210\u540e&#xff0c;\u8c03\u7528\u8005\u901a\u8fc7\u6808\u6307\u9488\u6216\u5176\u4ed6\u65b9\u6cd5\u4ece\u6307\u5b9a\u4f4d\u7f6e\u83b7\u53d6\u8fd4\u56de\u503c\u3002<\/li>\n<\/ul>\n<p>2.\u7cfb\u7edf\u5982\u4f55\u5f97\u77e5\u8fdb\u7a0b\u5f53\u524d\u6267\u884c\u5230\u54ea\u4e00\u884c\u4ee3\u7801\u4e86&#xff1f;<\/p>\n<p>CPU \u4e2d\u7684\u7a0b\u5e8f\u8ba1\u6570\u5668\u5bc4\u5b58\u5668 ( PC \u6216\u8005 eip ) \u4fdd\u5b58\u7740\u5f53\u524d\u6b63\u5728\u6267\u884c\u6307\u4ee4\u7684\u5730\u5740\u3002\u6bcf\u6b21\u6307\u4ee4\u6267\u884c\u5b8c\u6bd5&#xff0c;\u7a0b\u5e8f\u8ba1\u6570\u5668\u4f1a\u81ea\u52a8\u9012\u589e&#xff08;\u6216\u6839\u636e\u63a7\u5236\u6d41\u6307\u4ee4&#xff0c;\u5982 jmp\u3001call\u3001ret \u7b49\u66f4\u65b0&#xff09;&#xff0c;\u4ee5\u6307\u5411\u4e0b\u4e00\u6761\u9700\u8981\u6267\u884c\u7684\u6307\u4ee4\u3002<\/p>\n<p>\u8865\u5145\u77e5\u8bc6&#xff1a;\u5bc4\u5b58\u5668<\/p>\n<ul>\n<li>\n<p>CPU \u4e2d\u7684\u5bc4\u5b58\u5668\u6709\u5f88\u591a\u79cd&#xff0c;\u4f8b\u5982&#xff1a;\u901a\u7528\u5bc4\u5b58\u5668 eax\u3001ebx\u3001ecx\u3001edx&#xff1b;\u548c\u6808\u5e27\u6709\u5173\u7684\u5bc4\u5b58\u5668 ebp\u3001esp\u3001eip&#xff1b;\u548c\u72b6\u6001\u6709\u5173\u7684\u5bc4\u5b58\u5668 status\u3002<\/p>\n<\/li>\n<li>\n<p>\u5bc4\u5b58\u5668\u626e\u6f14\u4ec0\u4e48\u89d2\u8272&#xff1f;\u63d0\u9ad8\u6548\u7387&#xff0c;\u8fdb\u7a0b\u7684\u9ad8\u9891\u6570\u636e\u4f1a\u653e\u5165\u5bc4\u5b58\u5668\u4e2d\u3002<\/p>\n<\/li>\n<li>\n<p>\u5bc4\u5b58\u5668\u4e5f\u6709\u5bf9\u6570\u636e\u4fdd\u5b58\u7684\u80fd\u529b&#xff0c;\u8ba1\u7b97\u673a\u5728\u8fd0\u884c\u65f6\u4e00\u4e9b\u91cd\u8981\u7684\u6570\u636e\u4e00\u5b9a\u8981\u4fdd\u5b58\u5728 CPU \u5185\u90e8&#xff0c;\u5373\u5bc4\u5b58\u5668\u4e2d&#xff0c;\u56e0\u4e3a\u5bc4\u5b58\u5668\u79bb CPU \u5f88\u8fd1\u4e14\u5b58\u50a8\u6548\u7387\u9ad8&#xff0c;\u6240\u4ee5 CPU \u5185\u7684\u5bc4\u5b58\u5668\u4fdd\u5b58\u7684\u662f\u8fdb\u7a0b\u76f8\u5173\u7684\u6570\u636e&#xff0c;\u53ef\u4ee5\u968f\u65f6\u88ab CPU \u8bbf\u95ee\u6216\u8005\u4fee\u6539&#xff0c;\u8fd9\u79cd\u548c\u8fdb\u7a0b\u6709\u5173\u7684\u6570\u636e\u4e5f\u88ab\u53eb\u505a\u8fdb\u7a0b\u7684\u4e0a\u4e0b\u6587\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fdb\u7a0b\u5728 CPU \u4e0a\u79bb\u5f00\u65f6\u8981\u5c06\u81ea\u5df1\u7684\u4e0a\u4e0b\u6587\u6570\u636e\u4fdd\u5b58\u597d&#xff0c;\u751a\u81f3\u5e26\u8d70&#xff0c;\u8fd9\u6837\u505a\u7684\u76ee\u7684\u662f\u4e3a\u4e86\u672a\u6765\u201c\u56de\u6765\u201d\u7684\u65f6\u5019\u8fdb\u884c\u6062\u590d\u3002\u8fdb\u7a0b\u5728\u88ab\u5207\u6362\u7684\u65f6\u5019\u6709\u4e24\u6b65&#xff1a;**1. \u4fdd\u5b58\u4e0a\u4e0b\u6587&#xff0c;2. \u6062\u590d\u4e0a\u4e0b\u6587\u3002**\u8fdb\u7a0b\u7684\u4e0a\u4e0b\u6587\u6570\u636e\u91cf\u5e76\u4e0d\u5927&#xff0c;\u4e00\u822c\u53ef\u4ee5\u76f4\u63a5\u4fdd\u5b58\u5230\u8fdb\u7a0b\u7684 PCB \u5bf9\u8c61\u4e2d&#xff0c;\u5f53 CPU \u518d\u6b21\u8c03\u5ea6\u8be5\u8fdb\u7a0b\u7684\u65f6\u5019&#xff0c;\u5c06\u8fd9\u4e9b\u4e0a\u4e0b\u6587\u6570\u636e\u518d\u6062\u590d\u5230\u5bc4\u5b58\u5668\u91cc\u9762\u5373\u53ef\u3002<\/p>\n<\/li>\n<\/ul>\n<h3>\u4e09\u3001\u73af\u5883\u53d8\u91cf<\/h3>\n<p>\u73af\u5883\u53d8\u91cf\u662f\u64cd\u4f5c\u7cfb\u7edf\u7528\u4e8e\u5b58\u50a8\u7cfb\u7edf\u8303\u56f4\u5185\u6216\u7528\u6237\u7279\u5b9a\u4fe1\u606f\u7684\u952e\u503c\u5bf9&#xff0c;\u901a\u5e38\u7528\u4e8e\u914d\u7f6e\u7cfb\u7edf\u548c\u5e94\u7528\u7a0b\u5e8f\u8fd0\u884c\u65f6\u7684\u884c\u4e3a\u3002\u901a\u8fc7\u8bbe\u7f6e\u548c\u8bfb\u53d6\u73af\u5883\u53d8\u91cf&#xff0c;\u64cd\u4f5c\u7cfb\u7edf\u3001\u5f00\u53d1\u5de5\u5177\u548c\u5e94\u7528\u7a0b\u5e8f\u80fd\u591f\u66f4\u7075\u6d3b\u5730\u54cd\u5e94\u4e0d\u540c\u7684\u8fd0\u884c\u73af\u5883\u3002 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418130827-68024ecb66dd6.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> \u4e0a\u56fe\u662f Windows \u7cfb\u7edf\u4e0b\u7684\u73af\u5883\u53d8\u91cf&#xff0c;\u672c\u8d28\u4e0a\u5c31\u662f\u4e00\u7ec4\u952e\u503c\u5bf9&#xff0c;\u63a5\u4e0b\u6765\u5c06\u6f14\u793a Linux \u7cfb\u7edf\u4e0b\u5e38\u89c1\u7684\u73af\u5883\u53d8\u91cf\u3002<\/p>\n<h4>3.1 PATH\u2014\u2014\u641c\u7d22\u53ef\u6267\u884c\u6587\u4ef6\u7684\u76ee\u5f55\u5217\u8868<\/h4>\n<h5>1. \u4e3a\u4ec0\u4e48\u81ea\u5df1\u5199\u7684\u7a0b\u5e8f\u9700\u8981\u52a0 .\/ \u624d\u80fd\u6267\u884c&#xff1f;<\/h5>\n<ul>\n<li>\n<p>\u9ed8\u8ba4\u641c\u7d22\u8def\u5f84\u4e2d\u6ca1\u6709\u5f53\u524d\u76ee\u5f55&#xff1a;\u5f53\u524d\u76ee\u5f55&#xff08;.&#xff09;\u901a\u5e38\u5e76\u4e0d\u5305\u542b\u5728 PATH \u73af\u5883\u53d8\u91cf\u4e2d\u3002\u8fd9\u662f\u4e3a\u4e86\u907f\u514d\u5b89\u5168\u9690\u60a3&#xff08;\u9632\u6b62\u6076\u610f\u7a0b\u5e8f\u901a\u8fc7\u4f2a\u9020\u6307\u4ee4\u5e72\u6270\u7cfb\u7edf&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u52a0 .\/ \u7684\u4f5c\u7528&#xff1a;\u52a0 .\/ \u660e\u786e\u544a\u8bc9\u7cfb\u7edf&#xff0c;\u7a0b\u5e8f\u4f4d\u4e8e\u5f53\u524d\u76ee\u5f55\u4e0b\u3002\u4f8b\u5982&#xff1a;<\/p>\n<p> .\/my_program<\/p>\n<p>\u8868\u793a\u8fd0\u884c\u5f53\u524d\u76ee\u5f55\u4e0b\u540d\u4e3a my_program \u7684\u7a0b\u5e8f\u3002<\/p>\n<\/li>\n<\/ul>\n<h5>2. \u4e3a\u4ec0\u4e48\u6267\u884c\u6307\u4ee4\u65f6\u4e0d\u9700\u8981\u52a0\u8def\u5f84&#xff1f;<\/h5>\n<ul>\n<li>\n<p>\u6307\u4ee4&#xff08;\u5982 ls\u3001cat&#xff09;\u7684\u672c\u8d28&#xff1a;\u5b83\u4eec\u662f\u5b58\u653e\u5728\u7cfb\u7edf\u76ee\u5f55\u4e2d\u7684\u53ef\u6267\u884c\u7a0b\u5e8f&#xff0c;\u901a\u5e38\u4f4d\u4e8e \/usr\/bin\/ \u6216 \/bin\/ \u7b49\u76ee\u5f55\u4e0b\u3002<\/p>\n<\/li>\n<li>\n<p>PATH \u73af\u5883\u53d8\u91cf&#xff1a;Linux \u7cfb\u7edf\u901a\u8fc7 PATH \u73af\u5883\u53d8\u91cf\u6765\u6307\u5b9a\u4e00\u7cfb\u5217\u76ee\u5f55&#xff0c;\u5f53\u4f60\u5728\u7ec8\u7aef\u8f93\u5165\u6307\u4ee4\u65f6&#xff0c;\u7cfb\u7edf\u4f1a\u6309\u7167 PATH \u4e2d\u5b9a\u4e49\u7684\u76ee\u5f55\u987a\u5e8f&#xff0c;\u4f9d\u6b21\u67e5\u627e\u8be5\u6307\u4ee4\u5bf9\u5e94\u7684\u53ef\u6267\u884c\u7a0b\u5e8f\u3002<\/p>\n<\/li>\n<li>\n<p>\u67e5\u627e\u8fc7\u7a0b&#xff1a;<\/p>\n<ul>\n<li>\u8f93\u5165 ls \u65f6&#xff0c;\u7cfb\u7edf\u4f1a\u5728 PATH \u7684\u6240\u6709\u76ee\u5f55\u4e2d\u641c\u7d22 ls \u5bf9\u5e94\u7684\u7a0b\u5e8f&#xff08;\u5982 \/usr\/bin\/ls&#xff09;&#xff0c;\u4e00\u65e6\u627e\u5230&#xff0c;\u5c31\u76f4\u63a5\u6267\u884c\u3002<\/li>\n<li>\u5982\u679c\u672a\u627e\u5230&#xff0c;\u7cfb\u7edf\u4f1a\u62a5\u9519 command not found\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h5>3. \u5982\u4f55\u67e5\u770b\u548c\u4fee\u6539 PATH&#xff1f;<\/h5>\n<p>1. \u67e5\u770b PATH&#xff1a;<\/p>\n<p>echo $PATH<\/p>\n<p>\u8f93\u51fa\u793a\u4f8b&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418130827-68024ecba8879.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> \u8868\u793a\u7cfb\u7edf\u4f1a\u4f9d\u6b21\u5728 \/usr\/local\/bin\u3001\/usr\/bin\u3001\/bin \u7b49\u76ee\u5f55\u4e2d\u67e5\u627e\u547d\u4ee4\u3002<\/p>\n<p>2.\u4e34\u65f6\u6dfb\u52a0\u8def\u5f84\u5230 PATH&#xff1a;<\/p>\n<p>PATH&#061;$PATH:\/home\/xny\/linux\/lesson13<\/p>\n<ul>\n<li>\/home\/xny\/linux\/lesson13 \u662f\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u3002<\/li>\n<li>$PATH \u8868\u793a\u4fdd\u7559\u539f\u6709\u7684\u641c\u7d22\u8def\u5f84&#xff0c;\u4e0d\u8986\u76d6\u3002<\/li>\n<li>\u8be5\u4fee\u6539\u4ec5\u5bf9\u5f53\u524d\u7ec8\u7aef\u6709\u6548&#xff0c;\u5173\u95ed\u7ec8\u7aef\u540e\u4f1a\u6062\u590d\u9ed8\u8ba4\u3002 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418130827-68024ecbbb7d9.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> \u6b64\u65f6\u6211\u4eec\u5f53\u524d\u7684\u5de5\u4f5c\u76ee\u5f55\u4e5f\u88ab\u6dfb\u52a0\u4e86\u8fdb\u53bb&#xff0c;\u6b64\u65f6\u5728\u8be5\u76ee\u5f55\u4e0b\u7684\u53ef\u6267\u884c\u7a0b\u5e8f\u5728\u6267\u884c\u7684\u65f6\u5019\u5c31\u53ef\u4ee5\u4e0d\u52a0 .\/ \u4e86\u3002 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418130827-68024ecbd158a.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> \u5982\u56fe\u6240\u793a&#xff0c;mycmd\u53ef\u4ee5\u76f4\u63a5\u5f53\u4f5c\u547d\u4ee4\u4f7f\u7528\u4e86\u3002<\/li>\n<\/ul>\n<h4>3.2 HOME\u2014\u2014\u8868\u793a\u5f53\u524d\u7528\u6237\u7684\u4e3b\u76ee\u5f55\u8def\u5f84<\/h4>\n<h5>1. \u4ec0\u4e48\u662f HOME&#xff1f;<\/h5>\n<p>HOME \u662f Linux \u7cfb\u7edf\u4e2d\u7684\u4e00\u4e2a\u73af\u5883\u53d8\u91cf&#xff0c;\u5b83\u8868\u793a\u5f53\u524d\u7528\u6237\u7684\u4e3b\u76ee\u5f55\u8def\u5f84\u3002\u4e3b\u76ee\u5f55\u662f\u6bcf\u4e2a\u7528\u6237\u7684\u4e2a\u4eba\u5de5\u4f5c\u7a7a\u95f4&#xff0c;\u7528\u4e8e\u5b58\u50a8\u7528\u6237\u7684\u914d\u7f6e\u6587\u4ef6\u3001\u6587\u6863\u3001\u4e0b\u8f7d\u6587\u4ef6\u7b49\u3002\u4e0d\u540c\u7684\u7528\u6237\u62e5\u6709\u5404\u81ea\u7684\u4e3b\u76ee\u5f55&#xff0c;\u5f7c\u6b64\u9694\u79bb\u3002<\/p>\n<ul>\n<li>\u666e\u901a\u7528\u6237\u7684 HOME \u8def\u5f84&#xff1a;\u901a\u5e38\u4f4d\u4e8e \/home\/username\u3002<\/li>\n<li>\u8d85\u7ea7\u7528\u6237&#xff08;root&#xff09;\u7684 HOME \u8def\u5f84&#xff1a;\u9ed8\u8ba4\u4e3a \/root\u3002<\/li>\n<\/ul>\n<h5>2. \u4f5c\u4e3a\u9ed8\u8ba4\u5de5\u4f5c\u76ee\u5f55<\/h5>\n<ul>\n<li>\u7528\u6237\u767b\u5f55\u7cfb\u7edf\u65f6&#xff0c;Shell \u9ed8\u8ba4\u8fdb\u5165 HOME \u76ee\u5f55\u3002<\/li>\n<li>\u8f93\u5165 cd&#xff08;\u4e0d\u5e26\u53c2\u6570&#xff09;\u6216 cd ~ \u65f6&#xff0c;\u90fd\u4f1a\u5207\u6362\u5230 HOME \u76ee\u5f55\u3002<\/li>\n<\/ul>\n<h5>3. \u67e5\u770b HOME \u73af\u5883\u53d8\u91cf\u7684\u503c<\/h5>\n<p>echo $HOME<\/p>\n<p>\u793a\u4f8b\u8f93\u51fa&#xff1a; <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418130828-68024ecc1227d.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> \u6211\u4eec\u53ef\u4ee5\u901a\u8fc7 env \u6307\u4ee4\u67e5\u770b\u5f53\u524d bash \u4ece\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u7ee7\u627f\u4e0b\u6765\u7684\u6240\u6709\u73af\u5883\u53d8\u91cf\u3002 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418130828-68024ecc237a6.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> \u9664\u4e86\u4f7f\u7528 env \u6307\u4ee4&#xff0c;\u6211\u4eec\u8fd8\u53ef\u4ee5\u901a\u8fc7 getenv \u8fd9\u4e2a\u7cfb\u7edf\u8c03\u7528\u63a5\u53e3\u6765\u83b7\u53d6\u67d0\u4e2a\u73af\u5883\u53d8\u91cf\u7684\u503c\u3002<\/p>\n<h4>3.3 USER\u2014\u2014\u5b58\u50a8\u5f53\u524d\u767b\u5f55\u7528\u6237\u7684\u7528\u6237\u540d<\/h4>\n<p>USER \u662f\u4e00\u4e2a\u7cfb\u7edf\u73af\u5883\u53d8\u91cf&#xff0c;\u7528\u6765\u5b58\u50a8\u5f53\u524d\u767b\u5f55\u7528\u6237\u7684\u7528\u6237\u540d\u3002Linux \u7cfb\u7edf\u4f9d\u8d56\u6b64\u53d8\u91cf\u6765\u6807\u8bc6\u5f53\u524d\u7528\u6237&#xff0c;\u5e76\u6839\u636e\u5176\u6743\u9650\u7ea7\u522b&#xff08;\u5982\u666e\u901a\u7528\u6237\u6216 root \u7528\u6237&#xff09;\u63d0\u4f9b\u4e0d\u540c\u7684\u8bbf\u95ee\u6743\u9650\u3002<\/p>\n<h5>1. \u793a\u4f8b\u4ee3\u7801 1&#xff1a;\u6253\u5370\u5f53\u524d\u7528\u6237<\/h5>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;stdio.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;stdlib.h&gt;<\/span><\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;USER: %s\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token function\">getenv<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;USER&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u89e3\u91ca&#xff1a;<\/p>\n<li>\n<p>getenv(&#034;USER&#034;)&#xff1a;<\/p>\n<ul>\n<li>\u8c03\u7528 C \u6807\u51c6\u5e93\u51fd\u6570 getenv \u83b7\u53d6\u73af\u5883\u53d8\u91cf USER \u7684\u503c&#xff0c;\u5373\u5f53\u524d\u767b\u5f55\u7528\u6237\u7684\u7528\u6237\u540d\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u6253\u5370\u7ed3\u679c&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u4e0d\u540c\u7528\u6237\u8fd0\u884c\u6b64\u7a0b\u5e8f\u65f6&#xff0c;\u4f1a\u5f97\u5230\u5404\u81ea\u7684\u7528\u6237\u540d\u3002\u4f8b\u5982&#xff1a;<\/p>\n<p> <span class=\"token environment constant\">USER<\/span><span class=\"token builtin class-name\">:<\/span> root<\/p>\n<p>\u6216<\/p>\n<p> <span class=\"token environment constant\">USER<\/span><span class=\"token builtin class-name\">:<\/span> john\n <\/li>\n<\/ul>\n<\/li>\n<h5>2. \u793a\u4f8b\u4ee3\u7801 2&#xff1a;\u5224\u65ad\u7528\u6237\u6743\u9650<\/h5>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;stdio.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;stdlib.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;string.h&gt;<\/span><\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">char<\/span> user<span class=\"token punctuation\">[<\/span><span class=\"token number\">32<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">strcpy<\/span><span class=\"token punctuation\">(<\/span>user<span class=\"token punctuation\">,<\/span> <span class=\"token function\">getenv<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;USER&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">if<\/span><span class=\"token punctuation\">(<\/span><span class=\"token function\">strcmp<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;root&#034;<\/span><span class=\"token punctuation\">,<\/span> user<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;root\u7528\u6237&#xff0c;\u4e0d\u53d7\u6743\u9650\u7ea6\u675f\\\\n&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token keyword\">else<\/span><br \/>\n    <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u666e\u901a\u7528\u6237&#xff0c;\u53d7\u6743\u9650\u7ea6\u675f\\\\n&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;USER: %s\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token function\">getenv<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;USER&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span>    <\/p>\n<p>\u529f\u80fd&#xff1a;<\/p>\n<li>\u8bfb\u53d6\u73af\u5883\u53d8\u91cf USER&#xff1a;\n<ul>\n<li>\u4f7f\u7528 getenv(&#034;USER&#034;) \u83b7\u53d6\u5f53\u524d\u767b\u5f55\u7528\u6237\u540d\u3002<\/li>\n<li>\u5c06\u7528\u6237\u540d\u5b58\u50a8\u5728 user \u5b57\u7b26\u6570\u7ec4\u4e2d\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u5224\u65ad\u662f\u5426\u4e3a root \u7528\u6237&#xff1a;\n<ul>\n<li>\u4f7f\u7528 strcmp \u51fd\u6570\u5bf9\u6bd4\u7528\u6237\u540d\u662f\u5426\u4e3a root\u3002<\/li>\n<li>\u5982\u679c\u662f root&#xff0c;\u5219\u6253\u5370 \u201croot\u7528\u6237&#xff0c;\u4e0d\u53d7\u6743\u9650\u7ea6\u675f\u201d\u3002<\/li>\n<li>\u5982\u679c\u4e0d\u662f&#xff0c;\u5219\u6253\u5370 \u201c\u666e\u901a\u7528\u6237&#xff0c;\u53d7\u6743\u9650\u7ea6\u675f\u201d\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u6253\u5370\u5f53\u524d\u7528\u6237&#xff1a;\n<ul>\n<li>\u518d\u6b21\u6253\u5370\u5f53\u524d\u7528\u6237\u7684\u7528\u6237\u540d\u3002<\/li>\n<\/ul>\n<\/li>\n<p>\u8fd0\u884c\u7ed3\u679c\u793a\u4f8b&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u5982\u679c root \u7528\u6237\u8fd0\u884c\u7a0b\u5e8f&#xff1a;<\/p>\n<p> root\u7528\u6237&#xff0c;\u4e0d\u53d7\u6743\u9650\u7ea6\u675f<br \/>\n<span class=\"token environment constant\">USER<\/span><span class=\"token builtin class-name\">:<\/span> root\n <\/li>\n<li>\n<p>\u5982\u679c\u666e\u901a\u7528\u6237&#xff08;\u5982 john&#xff09;\u8fd0\u884c\u7a0b\u5e8f&#xff1a;<\/p>\n<p> \u666e\u901a\u7528\u6237&#xff0c;\u53d7\u6743\u9650\u7ea6\u675f<br \/>\n<span class=\"token environment constant\">USER<\/span><span class=\"token builtin class-name\">:<\/span> john\n <\/li>\n<\/ul>\n<h5>3. USER \u4e0e\u6743\u9650\u8ba4\u8bc1<\/h5>\n<li>\u7cfb\u7edf\u6743\u9650\u5224\u65ad&#xff1a;\n<ul>\n<li>Linux \u7cfb\u7edf\u4f1a\u4f7f\u7528\u5f53\u524d\u7528\u6237\u7684 USER \u53d8\u91cf\u4e0e\u6587\u4ef6\u7684\u62e5\u6709\u8005\u548c\u6743\u9650\u4fe1\u606f\u8fdb\u884c\u5bf9\u6bd4&#xff0c;\u5224\u65ad\u5f53\u524d\u7528\u6237\u662f\u5426\u6709\u6743\u8bbf\u95ee\u6216\u4fee\u6539\u6587\u4ef6\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u6743\u9650\u6a21\u578b&#xff1a;\n<ul>\n<li>\u6bcf\u4e2a\u6587\u4ef6\u6216\u76ee\u5f55\u90fd\u6709\u4e09\u7c7b\u6743\u9650&#xff1a;\n<ul>\n<li>\u62e5\u6709\u8005&#xff08;Owner&#xff09;&#xff1a;\u6587\u4ef6\u7684\u6240\u6709\u8005\u3002<\/li>\n<li>\u6240\u5c5e\u7ec4&#xff08;Group&#xff09;&#xff1a;\u6587\u4ef6\u6240\u5c5e\u7684\u7528\u6237\u7ec4\u3002<\/li>\n<li>\u5176\u4ed6\u7528\u6237&#xff08;Other&#xff09;&#xff1a;\u4e0d\u5c5e\u4e8e\u4ee5\u4e0a\u4e24\u7c7b\u7684\u7528\u6237\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u6743\u9650\u5206\u4e3a\u4e09\u79cd&#xff1a;\n<ul>\n<li>\u8bfb&#xff08;r&#xff09;\u3001\u5199&#xff08;w&#xff09;\u3001\u6267\u884c&#xff08;x&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>USER \u7684\u5b9e\u9645\u4f5c\u7528&#xff1a;\n<ul>\n<li>\u5f53\u7528\u6237\u6267\u884c\u67d0\u4e9b\u64cd\u4f5c&#xff08;\u5982\u8bbf\u95ee\u6587\u4ef6\u3001\u8fd0\u884c\u7a0b\u5e8f&#xff09;\u65f6&#xff0c;\u7cfb\u7edf\u4f1a\u83b7\u53d6 USER \u53d8\u91cf\u7684\u503c&#xff0c;\u5224\u65ad\u5f53\u524d\u7528\u6237\u662f\u5426\u6709\u5bf9\u5e94\u6743\u9650\u3002\u4f8b\u5982&#xff1a;\n<ul>\n<li>\u5982\u679c\u662f root \u7528\u6237&#xff0c;\u901a\u5e38\u4e0d\u53d7\u6743\u9650\u9650\u5236\u3002<\/li>\n<li>\u5982\u679c\u662f\u666e\u901a\u7528\u6237&#xff0c;\u5219\u9700\u8981\u5bf9\u6bd4\u6743\u9650\u4f4d\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<h3>\u56db\u3001\u547d\u4ee4\u884c\u53c2\u6570<\/h3>\n<h4>4.1 \u4ec0\u4e48\u662f\u547d\u4ee4\u884c\u53c2\u6570&#xff1f;<\/h4>\n<p>\u547d\u4ee4\u884c\u53c2\u6570\u662f\u6307\u5728\u8fd0\u884c\u7a0b\u5e8f\u65f6\u901a\u8fc7\u547d\u4ee4\u884c\u4f20\u9012\u7ed9\u7a0b\u5e8f\u7684\u53c2\u6570\u3002\u5b83\u4eec\u4f7f\u7a0b\u5e8f\u53ef\u4ee5\u63a5\u53d7\u5916\u90e8\u8f93\u5165&#xff0c;\u4ece\u800c\u6539\u53d8\u7a0b\u5e8f\u7684\u884c\u4e3a\u6216\u5904\u7406\u4e0d\u540c\u7684\u6570\u636e\u3002<\/p>\n<p>\u5728 C\/C&#043;&#043; \u4e2d&#xff0c;\u547d\u4ee4\u884c\u53c2\u6570\u901a\u8fc7 main \u51fd\u6570\u7684\u53c2\u6570 argc \u548c argv \u83b7\u53d6&#xff1a;<\/p>\n<ul>\n<li>argc&#xff08;argument count&#xff09;&#xff1a;\u53c2\u6570\u7684\u6570\u91cf\u3002<\/li>\n<li>argv&#xff08;argument vector&#xff09;&#xff1a;\u4e00\u4e2a\u5b57\u7b26\u4e32\u6570\u7ec4&#xff0c;\u6bcf\u4e2a\u5143\u7d20\u662f\u4e00\u4e2a\u53c2\u6570\u7684\u503c\u3002<\/li>\n<\/ul>\n<h4>4.2 main \u51fd\u6570\u7684\u5f62\u5f0f<\/h4>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> argc<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">char<\/span> <span class=\"token operator\">*<\/span>argv<span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<ul>\n<li>argc&#xff1a;\u8868\u793a\u53c2\u6570\u7684\u4e2a\u6570&#xff0c;\u5305\u62ec\u7a0b\u5e8f\u672c\u8eab\u7684\u540d\u79f0\u3002\n<ul>\n<li>\u5982\u679c\u7a0b\u5e8f\u8fd0\u884c\u65f6\u6ca1\u6709\u989d\u5916\u53c2\u6570&#xff0c;\u5219 argc \u503c\u4e3a 1\u3002<\/li>\n<\/ul>\n<\/li>\n<li>argv&#xff1a;\u4e00\u4e2a\u6307\u9488\u6570\u7ec4&#xff0c;\u5b58\u50a8\u6bcf\u4e2a\u53c2\u6570\u7684\u5b57\u7b26\u4e32\u3002\n<ul>\n<li>argv[0]&#xff1a;\u59cb\u7ec8\u662f\u7a0b\u5e8f\u7684\u540d\u79f0&#xff08;\u5305\u542b\u8def\u5f84&#xff09;\u3002<\/li>\n<li>argv[1] \u5230 argv[argc-1]&#xff1a;\u8868\u793a\u4f20\u9012\u7ed9\u7a0b\u5e8f\u7684\u5b9e\u9645\u53c2\u6570\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> argc<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">char<\/span><span class=\"token operator\">*<\/span> argv<span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> i <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">for<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">;<\/span> i <span class=\"token operator\">&lt;<\/span> argc<span class=\"token punctuation\">;<\/span> i<span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;argv[%d]-&gt;%s\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span>i<span class=\"token punctuation\">,<\/span> argv<span class=\"token punctuation\">[<\/span>i<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span> <\/p>\n<p>\u8fd0\u884c\u793a\u4f8b&#xff1a; <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418130828-68024ecc6dc72.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> \u547d\u4ee4\u884c\u53c2\u6570\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u4f20\u9012\u7ed9\u7a0b\u5e8f&#xff1a;<\/p>\n<ul>\n<li>\u5f53\u6211\u4eec\u5728\u547d\u4ee4\u884c\u8f93\u5165 .\/mycode -a -b -c \u65f6&#xff0c;bash \u4f1a\u5c06\u8fd9\u6574\u884c\u8f93\u5165\u5f53\u4f5c\u4e00\u4e2a\u5b57\u7b26\u4e32\u3002<\/li>\n<li>\u7136\u540e&#xff0c;bash \u4f7f\u7528\u7a7a\u683c\u4f5c\u4e3a\u5206\u9694\u7b26&#xff0c;\u5c06\u5b57\u7b26\u4e32\u62c6\u5206\u6210\u5355\u72ec\u7684\u90e8\u5206\u3002<\/li>\n<li>\u62c6\u5206\u540e\u7684\u90e8\u5206\u4f5c\u4e3a\u5b57\u7b26\u4e32&#xff0c;\u5b58\u50a8\u5728\u4e00\u4e2a\u5b57\u7b26\u4e32\u6570\u7ec4\u4e2d&#xff0c;\u8fd9\u4e2a\u6570\u7ec4\u7684\u9996\u5730\u5740\u4f20\u9012\u7ed9 argv&#xff0c;\u5176\u5927\u5c0f\u4f20\u9012\u7ed9 argc\u3002<\/li>\n<li>argv \u662f\u4e00\u4e2a\u6307\u9488\u6570\u7ec4&#xff0c;\u5176\u6700\u540e\u4e00\u4e2a\u5143\u7d20\u4f1a\u81ea\u52a8\u88ab\u8bbe\u7f6e\u4e3a NULL&#xff0c;\u7528\u6765\u6807\u8bc6\u53c2\u6570\u7ed3\u675f\u3002\u8fd9\u79cd\u8bbe\u8ba1\u7684\u597d\u5904\u662f\u65b9\u4fbf\u7a0b\u5e8f\u5728\u5904\u7406\u53c2\u6570\u65f6\u5feb\u901f\u68c0\u6d4b\u7ed3\u675f\u6807\u5fd7&#xff0c;\u800c\u4e0d\u7528\u4f9d\u8d56 argc\u3002<\/li>\n<\/ul>\n<h4>4.3 \u547d\u4ee4\u884c\u53c2\u6570\u7684\u4f5c\u7528<\/h4>\n<p>\u547d\u4ee4\u884c\u53c2\u6570\u7684\u4e00\u4e2a\u91cd\u8981\u4f5c\u7528\u662f\u4e3a\u7a0b\u5e8f\u3001\u6307\u4ee4\u6216\u5de5\u5177\u63d0\u4f9b\u7075\u6d3b\u7684\u9009\u9879\u652f\u6301&#xff0c;\u4ee5\u4fbf\u5b9e\u73b0\u4e0d\u540c\u7684\u529f\u80fd\u6216\u884c\u4e3a\u3002<\/p>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;stdio.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;string.h&gt;<\/span><\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> argc<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">char<\/span><span class=\"token operator\">*<\/span> argv<span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>argc <span class=\"token operator\">!&#061;<\/span> <span class=\"token number\">2<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span>  <span class=\"token comment\">\/\/ \u53c2\u6570\u6570\u91cf\u6821\u9a8c<\/span><br \/>\n        <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;.\/mycode [-a|-b|-c|-d]\\\\n&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span>    <\/p>\n<p>    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token function\">strcmp<\/span><span class=\"token punctuation\">(<\/span>argv<span class=\"token punctuation\">[<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;-a&#034;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span>  <span class=\"token comment\">\/\/ \u5224\u65ad\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f\u5426\u4e3a &#034;-a&#034;<\/span><br \/>\n        <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u529f\u80fd1\\\\n&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">else<\/span> <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token function\">strcmp<\/span><span class=\"token punctuation\">(<\/span>argv<span class=\"token punctuation\">[<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;-b&#034;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u529f\u80fd2\\\\n&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">else<\/span> <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token function\">strcmp<\/span><span class=\"token punctuation\">(<\/span>argv<span class=\"token punctuation\">[<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;-c&#034;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u529f\u80fd3\\\\n&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">else<\/span> <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token function\">strcmp<\/span><span class=\"token punctuation\">(<\/span>argv<span class=\"token punctuation\">[<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;-d&#034;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u529f\u80fd4\\\\n&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">else<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u529f\u80fd5\\\\n&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u8fd0\u884c\u793a\u4f8b&#xff1a; <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418130828-68024eccd053d.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> \u547d\u4ee4\u884c\u53c2\u6570\u6709\u4e00\u4e2a\u91cd\u8981\u7684\u4f5c\u7528&#xff0c;\u5b83\u53ef\u4ee5\u4e3a\u6307\u4ee4\u3001\u5de5\u5177\u3001\u8f6f\u4ef6\u7b49\u63d0\u4f9b\u547d\u4ee4\u884c\u9009\u9879\u7684\u652f\u6301\u3002<\/p>\n<h4>4.4 main\u51fd\u6570\u7684\u7b2c\u4e09\u4e2a\u53c2\u6570<\/h4>\n<p>\u9664\u4e86\u4e0a\u9762\u63d0\u5230\u7684 argc \u548c argv \u4e24\u4e2a\u53c2\u6570&#xff0c;main \u51fd\u6570\u8fd8\u6709\u7b2c\u4e09\u4e2a\u53c2\u6570 env&#xff0c;\u5b83\u4e5f\u662f\u4e00\u4e2a\u6307\u9488\u6570\u7ec4&#xff0c;\u5b58\u653e\u7684\u662f\u8be5\u8fdb\u7a0b\u7684\u73af\u5883\u53d8\u91cf\u3002<\/p>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;stdio.h&gt;<\/span><\/span><br \/>\n<span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> argc<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">char<\/span><span class=\"token operator\">*<\/span> argv<span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">char<\/span><span class=\"token operator\">*<\/span> env<span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> i <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">for<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">;<\/span> env<span class=\"token punctuation\">[<\/span>i<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span> i<span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;env[%d] -&gt; %s\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> i<span class=\"token punctuation\">,<\/span> env<span class=\"token punctuation\">[<\/span>i<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418130829-68024ecd12348.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<ul>\n<li>\n<p>\u5728 C\/C&#043;&#043; \u4e2d&#xff0c;\u7a0b\u5e8f\u901a\u5e38\u4f1a\u4f7f\u7528\u4e24\u5f20\u6838\u5fc3\u5411\u91cf\u8868&#xff1a;<\/p>\n<li>\n<p>\u547d\u4ee4\u884c\u53c2\u6570\u8868&#xff08;argc \u548c argv&#xff09;<\/p>\n<ul>\n<li>\u7528\u4e8e\u63a5\u6536\u7528\u6237\u901a\u8fc7\u547d\u4ee4\u884c\u4f20\u9012\u7684\u53c2\u6570\u3002<\/li>\n<li>\u63d0\u4f9b\u4e86\u7a0b\u5e8f\u8fd0\u884c\u65f6\u7684\u8f93\u5165\u7075\u6d3b\u6027\u548c\u52a8\u6001\u63a7\u5236\u80fd\u529b\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u73af\u5883\u53d8\u91cf\u8868&#xff08;env&#xff09;<\/p>\n<ul>\n<li>\u7528\u4e8e\u5b58\u50a8\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u7684\u5168\u5c40\u914d\u7f6e\u4fe1\u606f\u3002<\/li>\n<li>\u5305\u542b\u7528\u6237\u4fe1\u606f\u3001\u8bed\u8a00\u8bbe\u7f6e\u3001\u8def\u5f84\u53d8\u91cf\u7b49&#xff0c;\u4e14\u7531\u7236\u8fdb\u7a0b\u4f20\u9012\u7ed9\u5b50\u8fdb\u7a0b\u3002<\/li>\n<\/ul>\n<\/li>\n<\/li>\n<li>\n<p>\u8fd0\u884c\u6307\u4ee4\u4e0e\u7a0b\u5e8f\u7684\u5173\u7cfb&#xff1a;<\/p>\n<li>\n<p>\u547d\u4ee4\u884c\u53c2\u6570&#xff1a;<\/p>\n<ul>\n<li>\u6bcf\u4e2a\u547d\u4ee4\u884c\u6307\u4ee4\u90fd\u4f1a\u62c6\u89e3\u4e3a\u591a\u4e2a\u90e8\u5206&#xff0c;\u5206\u522b\u5b58\u50a8\u5728 argv \u6570\u7ec4\u4e2d\u3002<\/li>\n<li>\u7a0b\u5e8f\u8fd0\u884c\u65f6\u53ef\u4ee5\u901a\u8fc7 argv \u548c argc \u83b7\u53d6\u8fd9\u4e9b\u53c2\u6570&#xff0c;\u5e76\u6839\u636e\u53c2\u6570\u6267\u884c\u4e0d\u540c\u7684\u529f\u80fd\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u73af\u5883\u53d8\u91cf\u7ee7\u627f&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u5f53\u6211\u4eec\u5728 bash \u4e2d\u8fd0\u884c\u7a0b\u5e8f\u65f6&#xff0c;bash \u4f5c\u4e3a\u7236\u8fdb\u7a0b\u4f1a\u5c06\u5176\u73af\u5883\u53d8\u91cf\u4f20\u9012\u7ed9\u7a0b\u5e8f&#xff08;\u5b50\u8fdb\u7a0b&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd9\u4f7f\u5f97\u7a0b\u5e8f\u53ef\u4ee5\u901a\u8fc7\u8bfb\u53d6\u73af\u5883\u53d8\u91cf\u52a8\u6001\u9002\u5e94\u8fd0\u884c\u73af\u5883\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/li>\n<\/ul>\n<h4>4.5 \u73af\u5883\u53d8\u91cf\u7684\u7ee7\u627f<\/h4>\n<h5>\u9a8c\u8bc1\u5b50\u8fdb\u7a0b\u7ee7\u627f\u73af\u5883\u53d8\u91cf<\/h5>\n<p>\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf \u5728 Bash \u4e2d\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4&#xff1a;<\/p>\n<p><span class=\"token builtin class-name\">export<\/span> <span class=\"token assign-left variable\">MY_VALUE<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">12345678<\/span><\/p>\n<ul>\n<li>\u901a\u8fc7 export \u5c06\u672c\u5730\u53d8\u91cf\u8f6c\u5316\u4e3a\u73af\u5883\u53d8\u91cf\u3002<\/li>\n<\/ul>\n<p>\u7136\u540e\u518d\u67e5\u770b\u5f53\u524d\u7684\u73af\u5883\u53d8\u91cf&#xff1a; <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418130829-68024ecd5cdb3.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> \u4e0b\u9762\u6267\u884c\u5b50\u8fdb\u7a0b .\/mycmd&#xff0c;\u53ef\u4ee5\u53d1\u73b0\u5b83\u91cc\u9762\u4e5f\u6709 MY_VALUE \u8fd9\u4e2a\u73af\u5883\u53d8\u91cf&#xff0c;\u8bf4\u660e\u5b50\u8fdb\u7a0b mycmd \u7ee7\u627f\u4e86\u7236\u8fdb\u7a0b bash \u7684\u73af\u5883\u53d8\u91cf\u3002 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418130829-68024ecdcc3b7.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> \u6b63\u662f\u56e0\u4e3a\u5b50\u8fdb\u7a0b\u53ef\u4ee5\u7ee7\u627f\u7236\u8fdb\u7a0b\u7684\u73af\u5883\u53d8\u91cf&#xff0c;\u6240\u4ee5\u6211\u4eec\u5728 bash \u8f93\u5165\u7684\u6240\u6709\u6307\u4ee4\u90fd\u8981\u9075\u5b88\u6743\u9650&#xff0c;\u56e0\u4e3a\u8f93\u5165\u7684\u6240\u6709\u6307\u4ee4\u90fd\u53ef\u4ee5\u770b\u505a\u662f bash \u7684\u5b50\u8fdb\u7a0b&#xff0c;\u90fd\u7ee7\u627f\u4e86 bash \u7684\u73af\u5883\u53d8\u91cf\u3002\u901a\u8fc7\u4e0b\u9762\u8fd9\u6761\u6307\u4ee4\u53ef\u4ee5\u5220\u9664\u73af\u5883\u53d8\u91cf\u3002<\/p>\n<p><span class=\"token builtin class-name\">unset<\/span> MY_VALUE<\/p>\n<h3>\u4e94\u3001\u672c\u5730\u53d8\u91cf\u4e0e\u5185\u5efa\u547d\u4ee4<\/h3>\n<p>\u672c\u5730\u53d8\u91cf&#xff1a;\u5c31\u662f\u5728\u547d\u4ee4\u884c\u4e2d\u76f4\u63a5\u5b9a\u4e49\u7684\u53d8\u91cf\u3002<\/p>\n<ul>\n<li>\u672c\u5730\u53d8\u91cf\u662f\u901a\u8fc7 bash \u547d\u4ee4\u884c\u76f4\u63a5\u5b9a\u4e49\u7684&#xff0c;\u4ec5\u5728\u5f53\u524d bash \u4f1a\u8bdd\u4e2d\u6709\u6548\u3002<\/li>\n<li>\u672c\u5730\u53d8\u91cf\u4e0d\u80fd\u88ab\u5b50\u8fdb\u7a0b\u7ee7\u627f\u3002<\/li>\n<\/ul>\n<p>\u73af\u5883\u53d8\u91cf&#xff1a;<\/p>\n<ul>\n<li>\u73af\u5883\u53d8\u91cf\u662f\u53ef\u4ee5\u88ab\u5b50\u8fdb\u7a0b\u7ee7\u627f\u7684\u53d8\u91cf\u3002<\/li>\n<li>\u901a\u8fc7 export \u5c06\u672c\u5730\u53d8\u91cf\u8f6c\u5316\u4e3a\u73af\u5883\u53d8\u91cf\u3002 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418130830-68024ece47c0a.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/li>\n<\/ul>\n<p>\u67e5\u770b\u6240\u6709\u53d8\u91cf&#xff1a;\u4f7f\u7528 set \u67e5\u770b&#xff1a;<\/p>\n<p><span class=\"token builtin class-name\">set<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418130830-68024ece62b42.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h4>5.1 \u4e3a\u4ec0\u4e48 echo \u80fd\u6253\u5370\u672c\u5730\u53d8\u91cf<\/h4>\n<p>\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7 echo \u6307\u4ee4\u6253\u5370\u51fa\u672c\u5730\u53d8\u91cf&#xff0c;\u4e4b\u524d\u8bf4\u8fc7 echo \u4f5c\u4e3a\u6307\u4ee4&#xff0c;\u672c\u8d28\u4e0a\u4e5f\u662f\u4e00\u4e2a\u53ef\u6267\u884c\u7a0b\u5e8f&#xff0c;\u65e2\u7136\u662f\u53ef\u6267\u884c\u7a0b\u5e8f&#xff0c;\u90a3\u5c31\u4f1a\u521b\u5efa\u8fdb\u7a0b&#xff0c;\u4f46\u662f\u6211\u4eec\u53c8\u8bf4\u4e86\u5b50\u8fdb\u7a0b\u662f\u65e0\u6cd5\u7ee7\u627f\u7236\u8fdb\u7a0b\u7684\u672c\u5730\u53d8\u91cf&#xff0c;\u90a3\u4e3a\u4ec0\u4e48 echo \u53ef\u4ee5\u6253\u5370\u51fa\u7236\u8fdb\u7a0b bash \u7684\u672c\u5730\u53d8\u91cf\u5462&#xff1f;<\/p>\n<p>\u672c\u5730\u53d8\u91cf\u7684\u4f5c\u7528\u57df:\u4ec5\u5728\u5f53\u524d bash \u4f1a\u8bdd\u4e2d\u6709\u6548\u3002<\/p>\n<p>echo \u662f\u5185\u5efa\u547d\u4ee4:\u76f4\u63a5\u7531 bash \u6267\u884c&#xff0c;\u4e0d\u521b\u5efa\u5b50\u8fdb\u7a0b&#xff0c;\u56e0\u6b64\u53ef\u4ee5\u8bbf\u95ee bash \u7684\u672c\u5730\u53d8\u91cf\u3002<\/p>\n<p>\u5185\u5efa\u547d\u4ee4\u4e0e\u5e38\u89c4\u547d\u4ee4<\/p>\n<p>bash \u4e2d\u7684\u6307\u4ee4\u53ef\u4ee5\u5206\u4e3a\u4e24\u7c7b&#xff1a;<\/p>\n<li>\u5e38\u89c4\u547d\u4ee4&#xff1a;\n<ul>\n<li>\u901a\u8fc7\u521b\u5efa\u5b50\u8fdb\u7a0b\u6267\u884c\u7684\u5916\u90e8\u7a0b\u5e8f\u3002<\/li>\n<li>\u793a\u4f8b&#xff1a;\n<ul>\n<li>ls&#xff1a;\u4f7f\u7528 fork \u521b\u5efa\u5b50\u8fdb\u7a0b&#xff0c;\u7136\u540e\u6267\u884c execve \u52a0\u8f7d\u5916\u90e8\u7a0b\u5e8f\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u5185\u5efa\u547d\u4ee4&#xff1a;\n<ul>\n<li>\u7531 bash \u81ea\u8eab\u76f4\u63a5\u5b9e\u73b0&#xff0c;\u4e0d\u4f1a\u521b\u5efa\u5b50\u8fdb\u7a0b\u3002<\/li>\n<li>\u793a\u4f8b&#xff1a;\n<ul>\n<li>echo\u3001cd\u3001export\u3001set \u7b49\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<p>echo \u5c31\u662f\u4e00\u4e2a\u5185\u5efa\u547d\u4ee4&#xff0c;\u6267\u884c echo \u547d\u4ee4\u7684\u65f6\u5019\u5e76\u4e0d\u4f1a\u521b\u5efa\u5b50\u8fdb\u7a0b.<\/p>\n<p>\u540c\u6837\u7684&#xff0c;cd \u4e5f\u662f\u4e00\u4e2a\u5185\u5efa\u547d\u4ee4&#xff0c;\u7528\u4e8e\u5207\u6362\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u3002\u5176\u672c\u8d28\u662f\u8c03\u7528\u7cfb\u7edf\u63a5\u53e3 chdir()&#xff0c;\u76f4\u63a5\u6539\u53d8\u5f53\u524d\u8fdb\u7a0b\u7684\u5de5\u4f5c\u76ee\u5f55\u3002<\/p>\n<p>\u9664\u4e86\u4e0a\u9762\u63d0\u5230\u7684\u4e24\u79cd\u901a\u8fc7\u4ee3\u7801\u83b7\u53d6\u73af\u5883\u53d8\u91cf\u7684\u65b9\u6cd5&#xff08;\u547d\u4ee4\u884c\u7b2c\u4e09\u4e2a\u53c2\u6570\u3001getenv\u7cfb\u7edf\u63a5\u53e3&#xff09;\u5916&#xff0c;\u8fd8\u53ef\u4ee5\u901a\u8fc7\u5168\u5c40\u53d8\u91cf environ\u83b7\u53d6<\/p>\n<ul>\n<li>libc \u63d0\u4f9b\u7684\u5168\u5c40\u53d8\u91cf environ&#xff0c;\u6307\u5411\u73af\u5883\u53d8\u91cf\u8868\u3002<\/li>\n<li>\u9700\u8981 extern \u663e\u5f0f\u58f0\u660e\u540e\u4f7f\u7528&#xff1a;<\/li>\n<\/ul>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;stdio.h&gt;<\/span><\/span><br \/>\n<span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> argc<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">char<\/span> <span class=\"token operator\">*<\/span>argv<span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n<span class=\"token keyword\">extern<\/span> <span class=\"token keyword\">char<\/span> <span class=\"token operator\">*<\/span><span class=\"token operator\">*<\/span>environ<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">int<\/span> i <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">for<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">;<\/span> environ<span class=\"token punctuation\">[<\/span>i<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span> i<span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n<span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;%s\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> environ<span class=\"token punctuation\">[<\/span>i<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<hr \/>\n<h2>\u7ed3\u8bed<\/h2>\n<p>\u901a\u8fc7\u5bf9\u8fdb\u7a0b\u4f18\u5148\u7ea7\u548c\u73af\u5883\u53d8\u91cf\u7684\u6df1\u5165\u5b66\u4e60&#xff0c;\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0&#xff0c;\u5b83\u4eec\u5728 Linux \u7cfb\u7edf\u4e2d\u626e\u6f14\u7740\u4e0d\u53ef\u6216\u7f3a\u7684\u89d2\u8272\u3002\u8fdb\u7a0b\u4f18\u5148\u7ea7\u786e\u4fdd\u4e86\u591a\u4efb\u52a1\u7cfb\u7edf\u4e2d\u8d44\u6e90\u7684\u516c\u5e73\u7ade\u4e89\u548c\u9ad8\u6548\u5229\u7528&#xff0c;\u800c\u73af\u5883\u53d8\u91cf\u4e3a\u7cfb\u7edf\u548c\u7528\u6237\u7a0b\u5e8f\u7684\u4ea4\u4e92\u63d0\u4f9b\u4e86\u7075\u6d3b\u6027\u548c\u52a8\u6001\u914d\u7f6e\u7684\u80fd\u529b\u3002\u638c\u63e1\u5b83\u4eec\u4e0d\u4ec5\u80fd\u5e2e\u52a9\u6211\u4eec\u4f18\u5316\u7cfb\u7edf\u6027\u80fd&#xff0c;\u8fd8\u80fd\u63d0\u5347\u5728\u65e5\u5e38\u5f00\u53d1\u548c\u8fd0\u7ef4\u4e2d\u7684\u6548\u7387\u3002\u5e0c\u671b\u901a\u8fc7\u672c\u7bc7\u6587\u7ae0&#xff0c;\u80fd\u591f\u8ba9\u60a8\u5bf9 Linux \u7cfb\u7edf\u7684\u8fd0\u884c\u673a\u5236\u6709\u66f4\u6df1\u5165\u7684\u8ba4\u8bc6&#xff0c;\u52a9\u529b\u60a8\u7684\u5b66\u4e60\u4e0e\u5b9e\u8df5\u3002 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418130830-68024ece770ab.gif\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u4eca\u5929\u7684\u5206\u4eab\u5230\u8fd9\u91cc\u5c31\u7ed3\u675f\u5566&#xff01;\u5982\u679c\u89c9\u5f97\u6587\u7ae0\u8fd8\u4e0d\u9519\u7684\u8bdd&#xff0c;\u53ef\u4ee5\u4e09\u8fde\u652f\u6301\u4e00\u4e0b&#xff0c;17\u7684\u4e3b\u9875\u8fd8\u6709\u5f88\u591a\u6709\u8da3\u7684\u6587\u7ae0&#xff0c;\u6b22\u8fce\u5c0f\u4f19\u4f34\u4eec\u524d\u53bb\u70b9\u8bc4&#xff0c;\u60a8\u7684\u652f\u6301\u5c31\u662f17\u524d\u8fdb\u7684\u52a8\u529b&#xff01;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418130830-68024ece87b91.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb6.7k\u6b21\uff0c\u70b9\u8d5e100\u6b21\uff0c\u6536\u85cf87\u6b21\u3002\u5728 Linux \u7cfb\u7edf\u4e2d\uff0c\u8fdb\u7a0b\u548c\u73af\u5883\u53d8\u91cf\u662f\u64cd\u4f5c\u7cfb\u7edf\u7684\u6838\u5fc3\u7ec4\u6210\u90e8\u5206\u3002\u8fdb\u7a0b\u4f18\u5148\u7ea7\u51b3\u5b9a\u4e86\u8d44\u6e90\u5206\u914d\u7684\u5148\u540e\u987a\u5e8f\uff0c\u76f4\u63a5\u5f71\u54cd\u7cfb\u7edf\u6027\u80fd\uff1b\u800c\u73af\u5883\u53d8\u91cf\u5219\u63d0\u4f9b\u4e86\u4e00\u79cd\u7075\u6d3b\u7684\u65b9\u5f0f\uff0c\u7528\u4e8e\u4f20\u9012\u7cfb\u7edf\u914d\u7f6e\u4fe1\u606f\u4ee5\u53ca\u63a7\u5236\u7a0b\u5e8f\u7684\u8fd0\u884c\u73af\u5883\u3002\u672c\u7bc7\u6587\u7ae0\u5c06\u6df1\u5165\u63a2\u8ba8\u8fdb\u7a0b\u4f18\u5148\u7ea7\u7684\u6982\u5ff5\u3001\u8c03\u8282\u65b9\u6cd5\u53ca\u5176\u539f\u7406\uff0c\u4ee5\u53ca\u73af\u5883\u53d8\u91cf\u7684\u5b9a\u4e49\u3001\u7279\u6027\u548c\u5b9e\u9645\u5e94\u7528\uff0c\u5e2e\u52a9\u8bfb\u8005\u66f4\u597d\u5730\u7406\u89e3 Linux \u7cfb\u7edf\u7684\u6838\u5fc3\u673a\u5236\uff0c\u4ece\u800c\u5728\u5b9e\u9645\u5de5\u4f5c\u4e2d\u66f4\u9ad8\u6548\u5730\u8c03\u8bd5\u548c\u4f18\u5316\u7cfb\u7edf\u3002\u4f18\u5148\u7ea7\u7684\u5b9a\u4e49\u4f18\u5148\u7ea7\u51b3\u5b9a\u4e86\u591a\u4e2a\u8fdb\u7a0b\u7ade\u4e89 CPU \u65f6\uff0c\u54ea\u4e2a\u8fdb\u7a0b\u4f18\u5148\u83b7\u5f97 CPU \u65f6\u95f4\u7247\u3002\u533a\u522b\u4e8e\u6743\u9650\uff0c\u6743\u9650\u51b3\u5b9a\u80fd\u4e0d\u80fd\u6267\u884c\u3002_\u73af\u5883\u53d8\u91cf\u7684\u4f18\u5148\u7ea7\u5982\u4f55\u8c03\u6574<\/p>\n","protected":false},"author":2,"featured_media":14339,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[99,58,898,81,50,43,207,44],"topic":[],"class_list":{"0":"post-14357","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","6":"hentry","7":"category-server","8":"tag-java","9":"tag-linux","11":"tag-python","12":"tag-50","13":"tag-43","14":"tag-207","15":"tag-44"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4f18\u5148\u7ea7\u4e0e\u73af\u5883\u53d8\u91cf\u7684\u827a\u672f\uff1a\u9a7e\u9a6d Linux \u7cfb\u7edf\u7684\u6838\u5fc3 - \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\/14357.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4f18\u5148\u7ea7\u4e0e\u73af\u5883\u53d8\u91cf\u7684\u827a\u672f\uff1a\u9a7e\u9a6d Linux \u7cfb\u7edf\u7684\u6838\u5fc3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb6.7k\u6b21\uff0c\u70b9\u8d5e100\u6b21\uff0c\u6536\u85cf87\u6b21\u3002\u5728 Linux \u7cfb\u7edf\u4e2d\uff0c\u8fdb\u7a0b\u548c\u73af\u5883\u53d8\u91cf\u662f\u64cd\u4f5c\u7cfb\u7edf\u7684\u6838\u5fc3\u7ec4\u6210\u90e8\u5206\u3002\u8fdb\u7a0b\u4f18\u5148\u7ea7\u51b3\u5b9a\u4e86\u8d44\u6e90\u5206\u914d\u7684\u5148\u540e\u987a\u5e8f\uff0c\u76f4\u63a5\u5f71\u54cd\u7cfb\u7edf\u6027\u80fd\uff1b\u800c\u73af\u5883\u53d8\u91cf\u5219\u63d0\u4f9b\u4e86\u4e00\u79cd\u7075\u6d3b\u7684\u65b9\u5f0f\uff0c\u7528\u4e8e\u4f20\u9012\u7cfb\u7edf\u914d\u7f6e\u4fe1\u606f\u4ee5\u53ca\u63a7\u5236\u7a0b\u5e8f\u7684\u8fd0\u884c\u73af\u5883\u3002\u672c\u7bc7\u6587\u7ae0\u5c06\u6df1\u5165\u63a2\u8ba8\u8fdb\u7a0b\u4f18\u5148\u7ea7\u7684\u6982\u5ff5\u3001\u8c03\u8282\u65b9\u6cd5\u53ca\u5176\u539f\u7406\uff0c\u4ee5\u53ca\u73af\u5883\u53d8\u91cf\u7684\u5b9a\u4e49\u3001\u7279\u6027\u548c\u5b9e\u9645\u5e94\u7528\uff0c\u5e2e\u52a9\u8bfb\u8005\u66f4\u597d\u5730\u7406\u89e3 Linux \u7cfb\u7edf\u7684\u6838\u5fc3\u673a\u5236\uff0c\u4ece\u800c\u5728\u5b9e\u9645\u5de5\u4f5c\u4e2d\u66f4\u9ad8\u6548\u5730\u8c03\u8bd5\u548c\u4f18\u5316\u7cfb\u7edf\u3002\u4f18\u5148\u7ea7\u7684\u5b9a\u4e49\u4f18\u5148\u7ea7\u51b3\u5b9a\u4e86\u591a\u4e2a\u8fdb\u7a0b\u7ade\u4e89 CPU \u65f6\uff0c\u54ea\u4e2a\u8fdb\u7a0b\u4f18\u5148\u83b7\u5f97 CPU \u65f6\u95f4\u7247\u3002\u533a\u522b\u4e8e\u6743\u9650\uff0c\u6743\u9650\u51b3\u5b9a\u80fd\u4e0d\u80fd\u6267\u884c\u3002_\u73af\u5883\u53d8\u91cf\u7684\u4f18\u5148\u7ea7\u5982\u4f55\u8c03\u6574\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/14357.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-18T13:08:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418130827-68024ecb1f59a.gif\" \/>\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=\"6 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/14357.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/14357.html\",\"name\":\"\u4f18\u5148\u7ea7\u4e0e\u73af\u5883\u53d8\u91cf\u7684\u827a\u672f\uff1a\u9a7e\u9a6d Linux \u7cfb\u7edf\u7684\u6838\u5fc3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-18T13:08:31+00:00\",\"dateModified\":\"2025-04-18T13:08:31+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/14357.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/14357.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/14357.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4f18\u5148\u7ea7\u4e0e\u73af\u5883\u53d8\u91cf\u7684\u827a\u672f\uff1a\u9a7e\u9a6d Linux \u7cfb\u7edf\u7684\u6838\u5fc3\"}]},{\"@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":"\u4f18\u5148\u7ea7\u4e0e\u73af\u5883\u53d8\u91cf\u7684\u827a\u672f\uff1a\u9a7e\u9a6d Linux \u7cfb\u7edf\u7684\u6838\u5fc3 - \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\/14357.html","og_locale":"zh_CN","og_type":"article","og_title":"\u4f18\u5148\u7ea7\u4e0e\u73af\u5883\u53d8\u91cf\u7684\u827a\u672f\uff1a\u9a7e\u9a6d Linux \u7cfb\u7edf\u7684\u6838\u5fc3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb6.7k\u6b21\uff0c\u70b9\u8d5e100\u6b21\uff0c\u6536\u85cf87\u6b21\u3002\u5728 Linux \u7cfb\u7edf\u4e2d\uff0c\u8fdb\u7a0b\u548c\u73af\u5883\u53d8\u91cf\u662f\u64cd\u4f5c\u7cfb\u7edf\u7684\u6838\u5fc3\u7ec4\u6210\u90e8\u5206\u3002\u8fdb\u7a0b\u4f18\u5148\u7ea7\u51b3\u5b9a\u4e86\u8d44\u6e90\u5206\u914d\u7684\u5148\u540e\u987a\u5e8f\uff0c\u76f4\u63a5\u5f71\u54cd\u7cfb\u7edf\u6027\u80fd\uff1b\u800c\u73af\u5883\u53d8\u91cf\u5219\u63d0\u4f9b\u4e86\u4e00\u79cd\u7075\u6d3b\u7684\u65b9\u5f0f\uff0c\u7528\u4e8e\u4f20\u9012\u7cfb\u7edf\u914d\u7f6e\u4fe1\u606f\u4ee5\u53ca\u63a7\u5236\u7a0b\u5e8f\u7684\u8fd0\u884c\u73af\u5883\u3002\u672c\u7bc7\u6587\u7ae0\u5c06\u6df1\u5165\u63a2\u8ba8\u8fdb\u7a0b\u4f18\u5148\u7ea7\u7684\u6982\u5ff5\u3001\u8c03\u8282\u65b9\u6cd5\u53ca\u5176\u539f\u7406\uff0c\u4ee5\u53ca\u73af\u5883\u53d8\u91cf\u7684\u5b9a\u4e49\u3001\u7279\u6027\u548c\u5b9e\u9645\u5e94\u7528\uff0c\u5e2e\u52a9\u8bfb\u8005\u66f4\u597d\u5730\u7406\u89e3 Linux \u7cfb\u7edf\u7684\u6838\u5fc3\u673a\u5236\uff0c\u4ece\u800c\u5728\u5b9e\u9645\u5de5\u4f5c\u4e2d\u66f4\u9ad8\u6548\u5730\u8c03\u8bd5\u548c\u4f18\u5316\u7cfb\u7edf\u3002\u4f18\u5148\u7ea7\u7684\u5b9a\u4e49\u4f18\u5148\u7ea7\u51b3\u5b9a\u4e86\u591a\u4e2a\u8fdb\u7a0b\u7ade\u4e89 CPU \u65f6\uff0c\u54ea\u4e2a\u8fdb\u7a0b\u4f18\u5148\u83b7\u5f97 CPU \u65f6\u95f4\u7247\u3002\u533a\u522b\u4e8e\u6743\u9650\uff0c\u6743\u9650\u51b3\u5b9a\u80fd\u4e0d\u80fd\u6267\u884c\u3002_\u73af\u5883\u53d8\u91cf\u7684\u4f18\u5148\u7ea7\u5982\u4f55\u8c03\u6574","og_url":"https:\/\/www.wsisp.com\/helps\/14357.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-18T13:08:31+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418130827-68024ecb1f59a.gif"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"6 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/14357.html","url":"https:\/\/www.wsisp.com\/helps\/14357.html","name":"\u4f18\u5148\u7ea7\u4e0e\u73af\u5883\u53d8\u91cf\u7684\u827a\u672f\uff1a\u9a7e\u9a6d Linux \u7cfb\u7edf\u7684\u6838\u5fc3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-18T13:08:31+00:00","dateModified":"2025-04-18T13:08:31+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/14357.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/14357.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/14357.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u4f18\u5148\u7ea7\u4e0e\u73af\u5883\u53d8\u91cf\u7684\u827a\u672f\uff1a\u9a7e\u9a6d Linux \u7cfb\u7edf\u7684\u6838\u5fc3"}]},{"@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\/14357","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=14357"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/14357\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/14339"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=14357"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=14357"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=14357"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=14357"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}