{"id":52103,"date":"2024-12-03T13:31:52","date_gmt":"2024-12-03T05:31:52","guid":{"rendered":"https:\/\/fwq.ai\/blog\/52103\/"},"modified":"2024-12-03T13:31:52","modified_gmt":"2024-12-03T05:31:52","slug":"linux-path%e7%8e%af%e5%a2%83%e5%8f%98%e9%87%8f%e5%a6%82%e4%bd%95%e6%9f%a5%e7%9c%8b","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/52103\/","title":{"rendered":"Linux PATH\u73af\u5883\u53d8\u91cf\u5982\u4f55\u67e5\u770b"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>Linux PATH\u73af\u5883\u53d8\u91cf\u5982\u4f55\u67e5\u770b<\/h1>\n<p>\u672c\u7bc7\u6587\u7ae0\u7ed9\u5927\u5bb6\u5206\u4eab\u300aLinux PATH\u73af\u5883\u53d8\u91cf\u5982\u4f55\u67e5\u770b\u300b\uff0c\u8986\u76d6\u4e86\u6587\u7ae0\u7684\u5e38\u89c1\u57fa\u7840\u77e5\u8bc6\uff0c\u5176\u5b9e\u4e00\u4e2a\u8bed\u8a00\u7684\u5168\u90e8\u77e5\u8bc6\u70b9\u4e00\u7bc7\u6587\u7ae0\u662f\u4e0d\u53ef\u80fd\u8bf4\u5b8c\u7684\uff0c\u4f46\u5e0c\u671b\u901a\u8fc7\u8fd9\u4e9b\u95ee\u9898\uff0c\u8ba9\u8bfb\u8005\u5bf9\u81ea\u5df1\u7684\u638c\u63e1\u7a0b\u5ea6\u6709\u4e00\u5b9a\u7684\u8ba4\u8bc6(B \u6570)\uff0c\u4ece\u800c\u5f25\u8865\u81ea\u5df1\u7684\u4e0d\u8db3\uff0c\u66f4\u597d\u7684\u638c\u63e1\u5b83\u3002<\/p>\n<\/p>\n<blockquote>\n<p>Linux PATH\u73af\u5883\u53d8\u91cf\u662f\u51b3\u5b9aShell\u5c06\u5230\u54ea\u4e9b\u76ee\u5f55\u4e2d\u5bfb\u627e\u547d\u4ee4\u6216\u7a0b\u5e8f\u7684\u4e00\u4e2a\u53c2\u6570\uff0c\u5b83\u7684\u5185\u5bb9\u662f\u7531\u4e00\u5806\u76ee\u5f55\u7ec4\u6210\u7684\uff0c\u5404\u76ee\u5f55\u4e4b\u95f4\u7528\u5192\u53f7 \u201c:\u201d \u9694\u5f00\u3002\u5f53\u6267\u884c\u67d0\u4e2aLinux\u547d\u4ee4\u65f6\uff0cLinux\u4f1a\u4f9d\u7167PATH\u73af\u5883\u53d8\u91cf\u4e2d\u5305\u542b\u7684\u76ee\u5f55\u4f9d\u6b21\u641c\u5bfb\u8be5\u547d\u4ee4\u7684\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u4e00\u65e6\u627e\u5230\uff0c\u5373\u6b63\u5e38\u6267\u884c\uff1b\u53cd\u4e4b\uff0c\u5219\u63d0\u793a\u65e0\u6cd5\u627e\u5230\u8be5\u547d\u4ee4\u3002<\/p>\n<\/blockquote>\n<p><strong>\u4ec0\u4e48\u662f\u73af\u5883\u53d8\u91cf<\/strong><\/p>\n<p>Linux\u662f\u4e00\u4e2a\u591a\u7528\u6237\u64cd\u4f5c\u7cfb\u7edf\uff0c\u6bcf\u4e2a\u7528\u6237\u90fd\u6709\u81ea\u5df1\u4e13\u6709\u7684\u8fd0\u884c\u73af\u5883\u3002\u7528\u6237\u6240\u4f7f\u7528\u7684\u73af\u5883\u7531\u4e00\u7cfb\u5217\u53d8\u91cf\u6240\u5b9a\u4e49\uff0c\u8fd9\u4e9b\u53d8\u91cf\u88ab\u79f0\u4e3a\u73af\u5883\u53d8\u91cf\u3002\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u901a\u5e38\u90fd\u662f\u5927\u5199\u7684\u3002<\/p>\n<p>\u6bcf\u4e2a\u7528\u6237\u90fd\u53ef\u4ee5\u6839\u636e\u9700\u8981\u4fee\u6539\u81ea\u5df1\u7684\u73af\u5883\u53d8\u91cf\uff0c\u4ee5\u8fbe\u5230\u81ea\u5df1\u7684\u4f7f\u7528\u8981\u6c42\u3002\u5e38\u89c1\u7684\u73af\u5883\u53d8\u91cf\u5982\u4e0b\u8868\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u5e8f\u53f7<\/th>\n<th>\u53d8\u91cf<\/th>\n<th>\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>1<\/strong><\/td>\n<td><strong><code>PATH<\/code><\/strong><\/td>\n<td><strong>\u51b3\u5b9a\u4e86<code>Shell<\/code>\u5c06\u5230\u54ea\u4e9b\u76ee\u5f55\u4e2d\u5bfb\u627e<code>\u547d\u4ee4<\/code>\u6216<code>\u7a0b\u5e8f<\/code>\uff0c\u8fd9\u4e2a\u53d8\u91cf\u662f\u5728\u65e5\u5e38\u4f7f\u7528\u4e2d<code>\u7ecf\u5e38<\/code>\u9700\u8981\u4fee\u6539\u7684<code>\u53d8\u91cf<\/code><\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>2<\/strong><\/td>\n<td><strong><code>TERM<\/code><\/strong><\/td>\n<td><strong>\u6307\u5b9a<code>\u7cfb\u7edf\u7ec8\u7aef<\/code><\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>3<\/strong><\/td>\n<td><strong><code>SHELL<\/code><\/strong><\/td>\n<td><strong>\u5f53\u524d\u7528\u6237<code>Shell\u7c7b\u578b<\/code><\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>4<\/strong><\/td>\n<td><strong><code>HOME<\/code><\/strong><\/td>\n<td><strong>\u5f53\u524d\u7528\u6237<code>\u4e3b\u76ee\u5f55<\/code><\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>5<\/strong><\/td>\n<td><strong><code>LOGNAME<\/code><\/strong><\/td>\n<td><strong>\u5f53\u524d\u7528\u6237\u7684<code>\u767b\u5f55\u540d<\/code><\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>6<\/strong><\/td>\n<td><strong><code>USER<\/code><\/strong><\/td>\n<td><strong>\u5f53\u524d<code>\u7528\u6237\u540d<\/code><\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>7<\/strong><\/td>\n<td><strong><code>HISTSIZE<\/code><\/strong><\/td>\n<td><strong><code>\u5386\u53f2\u547d\u4ee4<\/code>\u8bb0\u5f55\u6570<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>8<\/strong><\/td>\n<td><strong><code>HOSTNAME<\/code><\/strong><\/td>\n<td><strong>\u6307<code>\u4e3b\u673a<\/code>\u7684\u540d\u79f0<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>9<\/strong><\/td>\n<td><strong><code>LANGUAGE<\/code><\/strong><\/td>\n<td><strong><code>\u8bed\u8a00<\/code>\u76f8\u5173\u7684<code>\u73af\u5883\u53d8\u91cf<\/code>\uff0c<code>\u591a\u8bed\u8a00<\/code>\u53ef\u4ee5\u4fee\u6539\u6b64\u73af\u5883\u53d8\u91cf<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>10<\/strong><\/td>\n<td><strong><code>MAIL<\/code><\/strong><\/td>\n<td><strong>\u5f53\u524d\u7528\u6237\u7684<code>\u90ae\u4ef6<\/code>\u5b58\u653e\u76ee\u5f55<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>11<\/strong><\/td>\n<td><strong><code>PS1<\/code><\/strong><\/td>\n<td><strong><code>\u57fa\u672c<\/code>\u63d0\u793a\u7b26 \uff1a<br \/>\uff081\uff09<code>root<\/code>\u7528\u6237\u662f<code>#<\/code><br \/>\uff082\uff09<code>\u666e\u901a<\/code>\u7528\u6237\u662f<code>$<\/code><\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>12<\/strong><\/td>\n<td><strong><code>PS2<\/code><\/strong><\/td>\n<td><strong><code>\u9644\u5c5e<\/code>\u63d0\u793a\u7b26\uff0c\u9ed8\u8ba4\u662f <code>&gt;<\/code><\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>13<\/strong><\/td>\n<td><strong><code>LS_COLORS<\/code><\/strong><\/td>\n<td><strong><code>ls<\/code>\u547d\u4ee4\u7ed3\u679c<code>\u989c\u8272<\/code>\u663e\u793a<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Linux PATH\u73af\u5883\u53d8\u91cf<\/strong><\/p>\n<p>Linux \u4e2d\u7684 PATH \u73af\u5883\u53d8\u91cf \u7684\u5185\u5bb9\u662f\u7531\u4e00\u5806\u76ee\u5f55\u7ec4\u6210\u7684\uff0c\u5404\u76ee\u5f55\u4e4b\u95f4\u7528\u5192\u53f7 \u201c:\u201d \u9694\u5f00\u3002\u5f53\u6267\u884c\u67d0\u4e2a Linux \u547d\u4ee4\u65f6\uff0cLinux \u4f1a\u4f9d\u7167 PATH \u73af\u5883\u53d8\u91cf\u4e2d\u5305\u542b\u7684\u76ee\u5f55\u4f9d\u6b21\u641c\u5bfb\u8be5\u547d\u4ee4\u7684\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u4e00\u65e6\u627e\u5230\uff0c\u5373\u6b63\u5e38\u6267\u884c\uff1b\u53cd\u4e4b\uff0c\u5219\u63d0\u793a\u65e0\u6cd5\u627e\u5230\u8be5\u547d\u4ee4\u3002<\/p>\n<p><strong>\u8bf4\u660e<\/strong><\/p>\n<p>\u4e5f\u5c31\u662f\u8bf4\u5f53\u7528\u6237\u5728 shell \u547d\u4ee4\u884c\u754c\u9762\u4e2d\u8f93\u5165\u4e00\u4e2a \u5916\u90e8\u547d\u4ee4 \u65f6\uff0c shell \u5fc5\u987b\u641c\u7d22\u7cfb\u7edf\u6765\u627e\u5230\u5bf9\u5e94\u7684\u7a0b\u5e8f\u3002 PATH \u73af\u5883\u53d8\u91cf\u5b9a\u4e49\u4e86\u7528\u4e8e\u8fdb\u884c\u547d\u4ee4\u548c\u7a0b\u5e8f\u67e5\u627e\u7684\u76ee\u5f55\u3002<\/p>\n<p>\u5982\u679c\u547d\u4ee4\u6216\u8005\u7a0b\u5e8f\u7684\u4f4d\u7f6e\u6ca1\u6709\u5305\u62ec\u5728 PATH \u53d8\u91cf\u4e2d\uff0c\u90a3\u4e48\u5982\u679c\u4e0d\u4f7f\u7528\u7edd\u5bf9\u8def\u5f84\u7684\u8bdd\uff0c shell \u662f\u6ca1\u6cd5\u627e\u5230\u7684\u3002\u5982\u679c\u60f3\u8981\u5728\u865a\u62df\u76ee\u5f55\u7ed3\u6784\u4e2d\u7684\u4efb\u4f55\u4f4d\u7f6e\u6267\u884c\u67d0\u4e2a\u7a0b\u5e8f\uff0c\u529e\u6cd5\u662f\u628a\u8fd9\u4e2a\u7a0b\u5e8f\u6240\u5728\u7684\u76ee\u5f55\u6dfb\u52a0\u5230 PATH \u73af\u5883\u53d8\u91cf\u4e2d\uff0c\u6216\u8005\u628a\u8fd9\u4e2a\u7a0b\u5e8f\u653e\u5728 \/ \u94fe\u63a5(ln) \u5230\u5df2\u7ecf\u5b58\u5728 PATH \u4e2d\u7684\u76ee\u5f55\u4e0b\u3002<\/p>\n<p><strong>\u67e5\u770bPATH\u73af\u5883\u53d8\u91cf<\/strong><\/p>\n<p>\u547d\u4ee4\u884c\u4e2d\u8f93\u5165<\/p>\n<pre>echo&nbsp;$PATH<\/pre>\n<p>\u6216\u8005\u8f93\u5165\uff1a<\/p>\n<pre>export<\/pre>\n<p>\u4f8b1\uff1a\u67e5\u770b\u73af\u5883\u53d8\u91cf echo $PATH<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20240410\/171274539266166bb0da593.jpg\" class=\"aligncenter\" title=\"Linux PATH\u73af\u5883\u53d8\u91cf\u5982\u4f55\u67e5\u770b\u63d2\u56fe\" alt=\"Linux PATH\u73af\u5883\u53d8\u91cf\u5982\u4f55\u67e5\u770b\u63d2\u56fe\" \/><\/p>\n<p>\u4f8b2\uff1a\u67e5\u770b\u73af\u5883\u53d8\u91cf export<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20240410\/171274539266166bb0dd86d.jpg\" class=\"aligncenter\" title=\"Linux PATH\u73af\u5883\u53d8\u91cf\u5982\u4f55\u67e5\u770b\u63d2\u56fe1\" alt=\"Linux PATH\u73af\u5883\u53d8\u91cf\u5982\u4f55\u67e5\u770b\u63d2\u56fe1\" \/><\/p>\n<p>\u7ec8\u4e8e\u4ecb\u7ecd\u5b8c\u5566\uff01\u5c0f\u4f19\u4f34\u4eec\uff0c\u8fd9\u7bc7\u5173\u4e8e\u300aLinux PATH\u73af\u5883\u53d8\u91cf\u5982\u4f55\u67e5\u770b\u300b\u7684\u4ecb\u7ecd\u5e94\u8be5\u8ba9\u4f60\u6536\u83b7\u591a\u591a\u4e86\u5427\uff01\u6b22\u8fce\u5927\u5bb6\u6536\u85cf\u6216\u5206\u4eab\u7ed9\u66f4\u591a\u9700\u8981\u5b66\u4e60\u7684\u670b\u53cb\u5427~\u7c73\u4e91\u516c\u4f17\u53f7\u4e5f\u4f1a\u53d1\u5e03\u6587\u7ae0\u76f8\u5173\u77e5\u8bc6\uff0c\u5feb\u6765\u5173\u6ce8\u5427\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Linux PATH\u73af\u5883\u53d8\u91cf\u5982\u4f55\u67e5\u770b \u672c\u7bc7\u6587\u7ae0\u7ed9\u5927\u5bb6\u5206\u4eab\u300aLinux PATH\u73af\u5883\u53d8\u91cf\u5982\u4f55\u67e5\u770b\u300b\uff0c\u8986\u76d6\u4e86\u6587\u7ae0\u7684\u5e38\u89c1\u57fa\u7840\u77e5\u8bc6\uff0c\u5176\u5b9e\u4e00\u4e2a\u8bed\u8a00\u7684\u5168\u90e8\u77e5\u8bc6\u70b9\u4e00\u7bc7\u6587\u7ae0\u662f\u4e0d\u53ef\u80fd\u8bf4\u5b8c\u7684\uff0c\u4f46\u5e0c\u671b\u901a\u8fc7\u8fd9\u4e9b\u95ee\u9898\uff0c\u8ba9\u8bfb\u8005\u5bf9\u81ea\u5df1\u7684\u638c\u63e1\u7a0b\u5ea6\u6709\u4e00\u5b9a\u7684\u8ba4\u8bc6(B \u6570)\uff0c\u4ece\u800c\u5f25\u8865\u81ea\u5df1\u7684\u4e0d\u8db3\uff0c\u66f4\u597d\u7684\u638c\u63e1\u5b83\u3002 Linux PATH\u73af\u5883\u53d8\u91cf\u662f\u51b3\u5b9aShell\u5c06\u5230\u54ea\u4e9b\u76ee\u5f55\u4e2d\u5bfb\u627e\u547d\u4ee4\u6216\u7a0b\u5e8f\u7684\u4e00\u4e2a\u53c2\u6570\uff0c\u5b83\u7684\u5185\u5bb9\u662f\u7531\u4e00\u5806\u76ee\u5f55\u7ec4\u6210\u7684\uff0c\u5404\u76ee\u5f55\u4e4b\u95f4\u7528\u5192\u53f7 \u201c:\u201d \u9694\u5f00\u3002\u5f53\u6267\u884c\u67d0\u4e2aLinux\u547d\u4ee4\u65f6\uff0cLinux\u4f1a\u4f9d\u7167PATH\u73af\u5883\u53d8\u91cf\u4e2d\u5305\u542b\u7684\u76ee\u5f55\u4f9d\u6b21\u641c\u5bfb\u8be5\u547d\u4ee4\u7684\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u4e00\u65e6\u627e\u5230\uff0c\u5373\u6b63\u5e38\u6267\u884c\uff1b\u53cd\u4e4b\uff0c\u5219\u63d0\u793a\u65e0\u6cd5\u627e\u5230\u8be5\u547d\u4ee4\u3002 \u4ec0\u4e48\u662f\u73af\u5883\u53d8\u91cf Linux\u662f\u4e00\u4e2a\u591a\u7528\u6237\u64cd\u4f5c\u7cfb\u7edf\uff0c\u6bcf\u4e2a\u7528\u6237\u90fd\u6709\u81ea\u5df1\u4e13\u6709\u7684\u8fd0\u884c\u73af\u5883\u3002\u7528\u6237\u6240\u4f7f\u7528\u7684\u73af\u5883\u7531\u4e00\u7cfb\u5217\u53d8\u91cf\u6240\u5b9a\u4e49\uff0c\u8fd9\u4e9b\u53d8\u91cf\u88ab\u79f0\u4e3a\u73af\u5883\u53d8\u91cf\u3002\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u901a\u5e38\u90fd\u662f\u5927\u5199\u7684\u3002 \u6bcf\u4e2a\u7528\u6237\u90fd\u53ef\u4ee5\u6839\u636e\u9700\u8981\u4fee\u6539\u81ea\u5df1\u7684\u73af\u5883\u53d8\u91cf\uff0c\u4ee5\u8fbe\u5230\u81ea\u5df1\u7684\u4f7f\u7528\u8981\u6c42\u3002\u5e38\u89c1\u7684\u73af\u5883\u53d8\u91cf\u5982\u4e0b\u8868\uff1a \u5e8f\u53f7 \u53d8\u91cf \u8bf4\u660e 1 PATH \u51b3\u5b9a\u4e86Shell\u5c06\u5230\u54ea\u4e9b\u76ee\u5f55\u4e2d\u5bfb\u627e\u547d\u4ee4\u6216\u7a0b\u5e8f\uff0c\u8fd9\u4e2a\u53d8\u91cf\u662f\u5728\u65e5\u5e38\u4f7f\u7528\u4e2d\u7ecf\u5e38\u9700\u8981\u4fee\u6539\u7684\u53d8\u91cf 2 TERM \u6307\u5b9a\u7cfb\u7edf\u7ec8\u7aef 3 SHELL \u5f53\u524d\u7528\u6237Shell\u7c7b\u578b 4 HOME \u5f53\u524d\u7528\u6237\u4e3b\u76ee\u5f55 5 LOGNAME \u5f53\u524d\u7528\u6237\u7684\u767b\u5f55\u540d 6 USER \u5f53\u524d\u7528\u6237\u540d 7 HISTSIZE \u5386\u53f2\u547d\u4ee4\u8bb0\u5f55\u6570 8 HOSTNAME \u6307\u4e3b\u673a\u7684\u540d\u79f0 9 LANGUAGE \u8bed\u8a00\u76f8\u5173\u7684\u73af\u5883\u53d8\u91cf\uff0c\u591a\u8bed\u8a00\u53ef\u4ee5\u4fee\u6539\u6b64\u73af\u5883\u53d8\u91cf 10 MAIL \u5f53\u524d\u7528\u6237\u7684\u90ae\u4ef6\u5b58\u653e\u76ee\u5f55 11 PS1 \u57fa\u672c\u63d0\u793a\u7b26 \uff1a\uff081\uff09root\u7528\u6237\u662f#\uff082\uff09\u666e\u901a\u7528\u6237\u662f$ 12 PS2 \u9644\u5c5e\u63d0\u793a\u7b26\uff0c\u9ed8\u8ba4\u662f &gt; 13 LS_COLORS [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-52103","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52103","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=52103"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52103\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=52103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=52103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=52103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}