{"id":291042,"date":"2024-04-22T05:29:01","date_gmt":"2024-04-21T21:29:01","guid":{"rendered":"https:\/\/lrxjmw.cn\/tslmljzkzhjb.html"},"modified":"2024-04-22T05:29:01","modified_gmt":"2024-04-21T21:29:01","slug":"tslmljzkzhjb","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/tslmljzkzhjb.html","title":{"rendered":"\u63a2\u7d22Linux set\u547d\u4ee4\uff1a\u7cbe\u51c6\u63a7\u5236\u73af\u5883\u53d8\u91cf\u4e0eShell\u8fd0\u884c\u7684\u91cd\u8981\u5229\u5668"},"content":{"rendered":"

Linux<\/a>\u5f00\u6e90\u64cd\u4f5c\u7cfb\u7edf<\/a>\u56e0\u5176\u9ad8\u5ea6\u7075\u6d3b\u7684\u81ea\u5b9a\u4e49\u548c\u914d\u7f6e\u80fd\u529b\u800c\u5e7f\u53d7\u597d\u8bc4\u3002\u5176\u4e2d\uff0cset\u6307\u4ee4\u4ee5\u5176\u4e30\u5bcc\u4e14\u9002\u5e94\u6027\u5f3a\u7684\u7279\u6027\uff0c\u5728\u73af\u5883\u53d8\u91cf\u8bbe\u7f6e\u53caShell\u8fd0\u884c\u7cbe\u7ec6\u63a7\u5236\u7b49\u9886\u57df\u53d1\u6325\u7740\u91cd\u8981\u4f5c\u7528\uff0c\u56e0\u6b64\u88ab\u5e7f\u6cdb\u91c7\u7eb3\u3002\u672c\u7bc7\u6587\u7ae0\u5c06\u6df1\u5165\u63a2\u8ba8Linuxset\u547d\u4ee4<\/a>\u7684\u591a\u79cd\u5e94\u7528\u65b9\u6cd5\u4ee5\u53ca\u4e0e\u5176\u76f8\u5173\u7684\u77e5\u8bc6\u4f53\u7cfb\u3002<\/p>\n

1.set\u547d\u4ee4\u6982\u8ff0<\/b><\/p>\n

Linux\u5185\u5efa\u7684Set\u6307\u4ee4\u662f\u4e00\u9879\u81f3\u5173\u91cd\u8981\u7684Shell\u547d\u4ee4\uff0c\u7528\u4e8e\u8c03\u8282\u548c\u63a7\u5236Shell\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u7684\u5404\u79cd\u53c2\u6570\u8bbe\u7f6e\u3002\u501f\u52a9Set\u6307\u4ee4\uff0c\u7528\u6237\u4e0d\u4ec5\u80fd\u8bbe\u5b9a\u73af\u5883\u53d8\u91cf\uff0c\u8fd8\u80fd\u5f00\u542f\u6216\u5173\u95ed\u7279\u5b9a\u529f\u80fd\uff0c\u4e43\u81f3\u521b\u5efa\u81ea\u5b9a\u4e49\u51fd\u6570\u7b49\u3002\u56e0\u6b64\uff0c\u65e0\u8bba\u5728\u811a\u672c\u7f16\u7a0b\u8fd8\u662f\u7cfb\u7edf\u7ba1\u7406\u9886\u57df\uff0cSet\u6307\u4ee4\u5747\u5177\u6709\u6781\u9ad8\u7684\u5b9e\u7528\u6027\u3002<\/p>\n

\u5728Linux\u4e2d\uff0cset\u547d\u4ee4\u901a\u5e38\u7528\u4e8e\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762\uff1a<\/p>\n

-\u7cbe\u51c6\u8c03\u6574\u4e0e\u53ca\u65f6\u53d8\u66f4\u73af\u5883\u53d8\u91cf\u914d\u7f6e\uff1a\u8fd0\u7528`set`\u547d\u4ee4\u7ec6\u81f4\u8c03\u6574\u53ca\u7075\u6d3b\u4fee\u6539SHELL\u73af\u5883\u53d8\u91cf\uff0c\u6df1\u5ea6\u4f18\u5316\u5176\u5b9e\u9645\u6548\u80fd\u53ca\u6240\u5c5e\u5b50\u7cfb\u7edf\u6027\u80fd\u3002<\/p>\n

-\u5229\u7528Set\u547d\u4ee4\u5bf9Shell\u53c2\u6570\u4e0e\u7279\u6027\u8fdb\u884c\u7cbe\u5bc6\u8c03\u63a7\uff1a\u5de7\u5999\u8fd0\u7528Set\u547d\u4ee4\u8c03\u6574\u5e76\u81ea\u5b9a\u4e49Shell\u7684\u8bf8\u591a\u529f\u80fd\u7279\u6027\uff0c\u5982\u8d4b\u4e88\u811a\u672c\u8fd0\u884c\u8bb8\u53ef\u6743\u7b49\uff0c\u4ee5\u5e94\u5bf9\u610f\u5916\u7684\u8c03\u8bd5\u9700\u6c42\u3002<\/p>\n

-\u7ed3\u5408Shell\u51fd\u6570\u7279\u6027\uff1a\u501f\u52a9set\u6307\u4ee4\uff0c\u53ef\u6709\u6548\u5730\u521b\u5efa\u590d\u6742\u529f\u80fd\u7684\u51fd\u6570\uff0c\u5e76\u5c06\u590d\u6742\u7684\u547d\u4ee4\u6216\u7a0b\u5e8f\u7ec4\u5408\u6210\u4fbf\u4e8e\u64cd\u4f5c\u548c\u8c03\u7528\u7684\u5f62\u5f0f\u3002<\/p>\n

2.set\u547d\u4ee4\u7684\u57fa\u672c\u7528\u6cd5<\/b><\/p>\n

\u5728Linux\u4e2d\uff0cset\u547d\u4ee4\u7684\u57fa\u672c\u7528\u6cd5\u5982\u4e0b\uff1a<\/p>\n

\n

bash\nset[\u9009\u9879][\u53c2\u6570]\n<\/pre>\n<\/p>\n

\u5176\u4e2d\uff0c\u9009\u9879\u548c\u53c2\u6570\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u7684\u9700\u6c42\u6765\u6307\u5b9a\uff0c\u5e38\u7528\u7684\u9009\u9879\u5305\u62ec\uff1a<\/p>\n

--e\u4e3b\u8981\u8d1f\u8d23\u811a\u672c\u6267\u884c\u6d41\u7a0b\u4e2d\u7684\u6545\u969c\u68c0\u6d4b\u53ca\u5f02\u5e38\u7ec8\u6b62\uff0c\u786e\u4fdd\u5728\u53d1\u751f\u9519\u8bef\u65f6\u7acb\u523b\u505c\u6b62\u8fdb\u7a0b\u3002<\/p>\n

--u:\u51c6\u786e\u68c0\u6d4b\u672a\u5b9a\u4e49\u53d8\u91cf\uff0c\u786e\u4fdd\u811a\u672c\u5728\u672a\u5b9a\u4e49\u53d8\u91cf\u65f6\u7acb\u5373\u7ec8\u6b62\u3002<\/p>\n

·\"-x\"\u529f\u80fd\uff1a\u53ef\u8be6\u7ec6\u8ddf\u8e2a\u6bcf\u9879\u6307\u4ee4\u53ca\u5176\u76f8\u5e94\u53c2\u6570\u7684\u6267\u884c\u60c5\u51b5\uff0c\u65b9\u4fbf\u8fdb\u884c\u811a\u672c\u8c03\u8bd5\u5de5\u4f5c\u3002<\/p>\n

\u901a\u8fc7set\u547d\u4ee4\u53ef\u4ee5\u8bbe\u7f6e\u4e0a\u8ff0\u9009\u9879\uff0c\u4f8b\u5982\uff1a<\/p>\n

set-e<\/p>\n

set-u<\/p>\n

set-x<\/p>\n

\u5404\u9879\u9009\u62e9\u53ef\u72ec\u7acb\u6216\u6574\u5408\u8fd0\u7528linux+set\u547d\u4ee4<\/strong>\uff0c\u56e0\u5e94\u5404\u7c7b\u60c5\u5883\u6240\u9700\u3002<\/p>\n

3.\u8bbe\u7f6e\u548c\u4fee\u6539\u73af\u5883\u53d8\u91cf<\/b><\/p>\n

\u5728Linux\u64cd\u4f5c\u7cfb\u7edf\u73af\u5883\u4e0b\uff0c\u73af\u5883\u53d8\u91cf\u5bf9\u7cfb\u7edf\u53ca\u7528\u6237\u7684\u5de5\u4f5c\u73af\u5883\u81f3\u5173\u91cd\u8981\u3002\u5176\u8bbe\u5b9a\u76f4\u63a5\u5f71\u54cd\u5404\u7c7b\u6307\u4ee4\u548c\u7a0b\u5e8f\u7684\u8fd0\u884c\u6548\u679c\u3002\u501f\u52a9set\u547d\u4ee4\uff0c\u53ef\u8fdb\u884c\u73af\u5883\u53d8\u91cf\u53c2\u6570\u7684\u914d\u7f6e\u4e0e\u8c03\u6574\uff0c\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n

set\u53d8\u91cf\u540d=\u503c<\/p>\n

\u4f8b\u5982\uff0c\u8981\u5c06PATH\u73af\u5883\u53d8\u91cf\u8bbe\u7f6e\u4e3a\u65b0\u7684\u503c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

\u8def\u5f84\u8bbe\u5b9a\u5e94\u5305\u542b\uff1a\/usr\/local\/bin,\/usr\/bin,\/bin\u3002<\/p>\n

\u6210\u529f\u5c06Path\u73af\u5883\u53d8\u91cf\u66f4\u6539\u4e3a\u9884\u5b9a\u8bbe\u5b9a\u7684\/usr\/local\/bin:\/usr\/bin:\/bin\u8def\u5f84\u3002<\/p>\n

\u6b64\u5916\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528set\u547d\u4ee4\u5220\u9664\u5df2\u5b9a\u4e49\u7684\u73af\u5883\u53d8\u91cf\uff0c\u4f8b\u5982\uff1a<\/p>\n

set-u\u53d8\u91cf\u540d<\/p>\n

\u8fd9\u6837\u5c31\u53ef\u4ee5\u5220\u9664\u6307\u5b9a\u7684\u73af\u5883\u53d8\u91cf\u3002<\/p>\n

4.\u63a7\u5236Shell\u6267\u884c\u9009\u9879<\/b><\/p>\n

\u9664\u73af\u5883\u53d8\u91cf\u8bbe\u5b9a\u5916\uff0c\u501f\u52a9Set\u547d\u4ee4\u53ef\u7cbe\u7ec6\u5316\u8c03\u6574Shell\u8fd0\u884c\u73af\u5883\uff0c\u7075\u6d3b\u542f\u7528\u6216\u7981\u7528\u5404\u5f0f\u529f\u80fd\u3002\u4e3e\u4f8b\u6765\u8bf4\uff0c\u901a\u8fc7\u5229\u7528\u8bbe\u7f6e-e\u53c2\u6570linux+set\u547d\u4ee4<\/strong>linux\u670d\u52a1\u5668\u7cfb\u7edf\uff0c\u811a\u672c\u9519\u8bef\u76d1\u63a7\u673a\u5236\u5f97\u4ee5\u5f00\u542f\uff0c\u786e\u4fdd\u5728\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u5982\u9047\u9519\u8bef\u7acb\u5373\u505c\u6b62\u6267\u884c\uff0c\u8fd9\u5bf9\u4e8e\u6253\u9020\u9ad8\u6548\u3001\u7a33\u5b9a\u7684Shell\u811a\u672c\u5c24\u4e3a\u91cd\u8981\uff0c\u80fd\u5feb\u901f\u8bc6\u522b\u5e76\u4fee\u590d\u95ee\u9898\uff0c\u63d0\u5347\u811a\u672c\u7684\u7a33\u5b9a\u6027\u4e0e\u53ef\u9760\u6027\u3002<\/p>\n

5.\u5b9a\u4e49Shell\u51fd\u6570<\/b><\/p>\n

\u5728LinuxShell\u7f16\u7a0b\u7684\u4e16\u754c\u91cc\uff0c\u51fd\u6570\u53d1\u6325\u4e86\u91cd\u8981\u4f5c\u7528\uff0c\u5b83\u80fd\u5c06\u7e41\u7410\u7684\u64cd\u4f5c\u8fdb\u884c\u6574\u5408\u4e0e\u5c01\u88c5\uff0c\u4f7f\u4e4b\u66f4\u6613\u4e8e\u4f7f\u7528\u3002SET\u547d\u4ee4\u662f\u8bbe\u5b9a\u548c\u5efa\u7acbShell\u51fd\u6570\u7684\u5173\u952e\u5de5\u5177linux\u9a71\u52a8\u4e0b\u8f7d\uff0c\u4ee5\u4e0b\u4e3a\u5176\u6267\u884c\u6d41\u7a0b\uff1a<\/p>\n

set-f\u51fd\u6570\u540d(){<\/p>\n

\u547d\u4ee4\u5e8f\u5217<\/p>\n

}<\/p>\n

\u4f8b\u5982\uff1a\u6784\u5efa\u4e00\u6b3e\u4e13\u95e8\u53d1\u9001\"HelloWorld\"\u6d88\u606f\u7684\u7b80\u660eshell<\/a>\u5de5\u5177\u3002<\/p>\n

set-fhello(){<\/p>\n

echo\"HelloWorld\"<\/p>\n

\u5b9a\u4e49\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u51fd\u6570\u540d\u6765\u8c03\u7528\u8be5\u51fd\u6570\uff0c\u4f8b\u5982\uff1a<\/p>\n

hello<\/p>\n

\u8fd9\u6837\u5c31\u4f1a\u5728Shell\u4e2d\u6253\u5370\u51faHelloWorld\u7684\u6d88\u606f\u3002<\/p>\n

6.set\u547d\u4ee4\u7684\u5176\u4ed6\u7528\u6cd5<\/b><\/p>\n

\u9664\u4e86\u4e0a\u8ff0\u5e38\u89c1\u7528\u6cd5\u5916\uff0cset\u547d\u4ee4\u8fd8\u6709\u4e00\u4e9b\u5176\u4ed6\u7528\u6cd5\uff0c\u4f8b\u5982\uff1a<\/p>\n

-\u4f7f\u7528set\u547d\u4ee4\u67e5\u770b\u5f53\u524d\u7684Shell\u8bbe\u7f6e\u548c\u73af\u5883\u53d8\u91cf\u3002<\/p>\n

-Set\u6307\u4ee4\u53ef\u9488\u5bf9Shell\u8fd0\u884c\u73af\u5883\u53ca\u7279\u6027\u8fdb\u884c\u7cbe\u786e\u8c03\u8282\uff0c\u5982\u53d8\u66f4\u547d\u4ee4\u641c\u7d22\u8def\u5f84\u4e0e\u5386\u53f2\u8bb0\u5f55\u5b58\u50a8\u65b9\u6cd5\u3002<\/p>\n

\u501f\u52a9`set`\u547d\u4ee4\uff0c\u53ef\u4ee5\u5de7\u5999\u5730\u8c03\u6574Shell\u7a0b\u5e8f\u7684\u8f93\u5165\/\u8f93\u51fa\u65b9\u5411\u3002\u4f8b\u5982\uff0c\u6211\u4eec\u53ef\u5229\u7528\u6b64\u529f\u80fd\u5c06\u6807\u51c6\u8f93\u51fa\u8f6c\u6362\u6210\u6587\u4ef6\u5185\u5bb9\uff1b\u6216\u8005\u5c06\u6807\u51c6\u9519\u8bef\u8f93\u51fa\u91cd\u65b0\u8bbe\u7f6e\u4e3a\u6807\u51c6\u8f93\u51fa\u3002<\/p>\n

7.\u603b\u7ed3\u4e0e\u5c55\u671b<\/b><\/p>\n

\u672c\u6b21\u7814\u8ba8\u6df1\u5165\u5256\u6790\u4e86Linux\u7cfb\u7edf\u5185\u90e8Set\u547d\u4ee4\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\u7684\u91cd\u8981\u6027\u3002\u4f5c\u4e3aShell\u7a0b\u5e8f\u8bbe\u8ba1\u7684\u5173\u952e\u6280\u672f\u624b\u6bb5\uff0cSet\u547d\u4ee4\u5177\u5907\u8c03\u6574\u73af\u5883\u53c2\u6570\u53ca\u7cbe\u786e\u63a7\u5236Shell\u6267\u884c\u6d41\u7a0b\u4e0e\u51fd\u6570\u5b9a\u4e49\u7b49\u591a\u91cd\u529f\u80fd\u3002\u56e0\u6b64\uff0c\u719f\u7ec3\u8fd0\u7528Set\u547d\u4ee4\u5c06\u6781\u5927\u63d0\u5347Shell\u7f16\u7a0b\u7684\u6548\u7387\u4e0e\u8d28\u91cf\u3002<\/p>\n

\u4f34\u968f\u7740Linux\u64cd\u4f5c\u7cfb\u7edf\u7684\u65e5\u76ca\u8fdb\u6b65\u4e0e\u6210\u719f\uff0cSet\u547d\u4ee4\u7684\u5e94\u7528\u524d\u666f\u5e7f\u9614\uff0c\u5176\u529f\u80fd\u5c06\u5f97\u5230\u6df1\u5ea6\u6269\u5c55\u5e76\u5f97\u5230\u5927\u5e45\u63d0\u9ad8\uff0c\u4ee5\u671f\u4e3a\u5e7f\u5927\u7528\u6237\u5e26\u6765\u66f4\u52a0\u4fbf\u6377\u6709\u6548\u7684Shell\u7f16\u7a0b\u4f53\u9a8c\u3002\u4e3a\u6b64\uff0c\u6709\u5fc5\u8981\u7d27\u8ddfLinux\u793e\u533a\u7684\u6b65\u4f10\uff0c\u6d1e\u5bdf\u524d\u6cbf\u79d1\u6280\u52a8\u6001\u4ee5\u53ca\u8f6f\u4ef6\u5de5\u5177\u7684\u5e94\u7528\uff0c\u5e76\u5e94\u5bf9\u5feb\u901f\u53d8\u5316\u7684\u5e02\u573a\u9700\u6c42\u548c\u6fc0\u70c8\u7684\u7ade\u4e89\u6001\u52bf\u3002<\/p>\n

\u672c\u6587\u81f4\u529b\u4e8e\u6df1\u5165\u89e3\u6790\u5e76\u719f\u7ec3\u8fd0\u7528Linux\u7cfb\u7edf\u4e2d\u7684set\u547d\u4ee4\u3002\u82e5\u5bf9\u6b64\u6709\u6240\u7591\u8651\u6216\u5efa\u8bae\uff0c\u656c\u8bf7\u968f\u65f6\u63d0\u51fa\uff0c\u6211\u4eec\u671f\u5f85\u4e0e\u60a8\u5171\u540c\u63a2\u8ba8\u4e0e\u5206\u4eab\u7ecf\u9a8c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

Linux\u5185\u5efa\u7684Set\u6307\u4ee4\u662f\u4e00\u9879\u81f3\u5173\u91cd\u8981\u7684Shell\u547d\u4ee4\uff0c\u7528\u4e8e\u8c03\u8282\u548c\u63a7\u5236Shell\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u7684\u5404\u79cd\u53c2\u6570\u8bbe\u7f6e\u3002\u5728Linux\u64cd\u4f5c\u7cfb\u7edf\u73af\u5883\u4e0b\uff0c\u73af\u5883\u53d8\u91cf\u5bf9\u7cfb\u7edf\u53ca\u7528\u6237\u7684\u5de5\u4f5c\u73af\u5883\u81f3\u5173\u91cd\u8981\u3002\u9664\u73af\u5883\u53d8\u91cf\u8bbe\u5b9a\u5916\uff0c\u501f\u52a9Set\u547d\u4ee4\u53ef\u7cbe\u7ec6\u5316\u8c03\u6574Shell\u8fd0\u884c\u73af\u5883\uff0c\u7075\u6d3b\u542f\u7528\u6216\u7981\u7528\u5404\u5f0f\u529f\u80fd\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[988],"tags":[999],"class_list":["post-291042","post","type-post","status-publish","format-standard","hentry","category-tougao","tag-999"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/291042","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=291042"}],"version-history":[{"count":0,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/291042\/revisions"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=291042"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=291042"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=291042"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}