{"id":295367,"date":"2025-01-03T20:02:01","date_gmt":"2025-01-03T12:02:01","guid":{"rendered":"https:\/\/lrxjmw.cn\/lxtzhjblysbl.html"},"modified":"2025-01-03T20:02:01","modified_gmt":"2025-01-03T12:02:01","slug":"lxtzhjblysbl","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/lxtzhjblysbl.html","title":{"rendered":"Linux\u7cfb\u7edf\u4e2d\u73af\u5883\u53d8\u91cf\u4e0eShell\u53d8\u91cf\u7684\u8bbe\u7f6e\u4e0e\u67e5\u770b\u65b9\u6cd5\u8be6\u89e3"},"content":{"rendered":"

\u4f60\u4eec\u597d\uff0c\u53c8\u78b0\u9762\u4e86\uff0c\u6211\u662f\u5927\u5bb6\u7684\u540c\u4e8b\u5168\u6808\u541b\u3002<\/p>\n

\u660e\u5929\u5c0f\u7f16\u8981\u8ddf\u4f60\u4eec\u5206\u4eab\u7684\u6587\u7ae0\u662f\u5173\u4e8eLinux<\/a>\u7cfb\u7edf\u4e2d\u7684\u73af\u5883\u53d8\u91cf\u8be5\u600e\u4e48\u8bbe\u7f6e\u4e0e\u67e5\u770b\u3002\u4f60\u4eec\u90fd\u6653\u5f97\uff0c\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u6709\u73af\u5883\u53d8\u91cf\u548cShell<\/p>\n

\u53d8\u91cf\u8fd9\u4e24\u79cd\u53d8\u91cf\u3002<\/p>\n

\u73af\u5883\u53d8\u91cf\u662f\u5728\u7a0b\u5e8f\u53ca\u5176\u5b50\u7a0b\u5e8f\u4e2d\u5168\u5c40\u53ef\u7528\u7684\uff0c\u7ecf\u5e38\u62ff\u6765\u5b58\u50a8\u50cf\u9ed8\u8ba4\u7684\u6587\u672c\u7f16\u8f91\u5668\u6216\u5219\u6d4f\u89c8\u5668\uff0c\u4ee5\u53ca\u53ef\u6267\u884c\u6587\u4ef6\u7684\u8def\u5f84\u7b49\u7b49\u8fd9\u6837\u7684\u4fe1\u606f\u3002\u800cShell\u53d8\u91cf\u4ec5\u5728\u5f53\u524d<\/p>\n

Shell\u4e2d\u53ef\u7528\uff0c\u53ef\u4ee5\u62ff\u6765\u50a8\u5b58\u5f53\u524d\u7528\u6237\u7684ID\u7b49\u4fe1\u606f\u3002<\/p>\n

\u8fd9\u4e48\u54ea\u4e9b\u662f\u73af\u5883\u53d8\u91cf\uff0c\u54ea\u4e9b\u662fShell\u53d8\u91cf\uff0c\u8be5\u600e\u4e48\u8bbe\u7f6e\u548c\u67e5\u770b\u8fd9\u4e24\u79cd\u53d8\u91cf\u5462?\u4e0b\u8fb9\u6765\u548c\u5c0f\u7f16\u4e00\u8d77\u770b\u4e00\u770b\u5427\uff01<\/p>\n

linux\u73af\u5883\u53d8\u91cf\u8def\u5f84_linux\u8def\u5f84\u53d8\u91cf_linux\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u8def\u5f84<\/p>\n

\u4e00\u3001\u73af\u5883\u53d8\u91cf<\/p>\n

\u73af\u5883\u53d8\u91cf\u662f\u4ee5\u901a\u914d\u7b26\u5bf9\u7684\u65b9\u5f0f\u5b9e\u73b0\u7684\uff0c\u662f\u5728\u6574\u4e2a\u7cfb\u7edf\u8303\u56f4\u5185\u90fd\u53ef\u7528\u7684\u53d8\u91cf\uff0c\u5e76\u7531\u6240\u6709\u6d3e\u751f\u7684\u5b50\u8fdb\u7a0b\u548cShell<\/p>\n

\u627f\u7ee7\u3002\u800c\u73af\u5883\u53d8\u91cf\u7684\u540d\u79f0\u662f\u5206\u8fa8\u5927\u5c0f\u5199\u7684\uff0c\u4e14\u4e00\u822c\u4ee5\u5c0f\u5199\u7684\u65b9\u5f0f\u547d\u540d(MYVAR1,MYVAR2\u2026)<\/p>\n

\u5355\u4e2a\u503c\u7684\u73af\u5883\u53d8\u91cf\u770b\u4e0a\u53bb\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n

KEY=value1<\/p>\n

\u5047\u5982\u4f60\u60f3\u8981\u5c06\u591a\u4e2a\u503c\u8d4b\u4e8e\u73af\u5883\u53d8\u91cf\uff0c\u5219\u4e00\u822c\u7528\u9017\u53f7(:)\u4f5c\u4e3a\u5206\u9694\u7b26\u3002\u6bcf\u4e00\u5bf9\u901a\u914d\u7b26\u5bf9\u6700\u7ec8\u770b\u4e0a\u53bb\u662f\u8fd9\u6837\u5b50\u7684\uff1a<\/p>\n

KEY=value1:value2:value3<\/p>\n

\u5047\u5982\u8981\u8d4b\u4e8e\u73af\u5883\u53d8\u91cf\u7684\u503c\u5305\u542b\u7a7a\u683clinux\u8f6f\u4ef6linux\u67e5\u770b\u8fdb\u7a0b\uff0c\u5219\u987b\u8981\u4f7f\u7528\u5192\u53f7\uff1a<\/p>\n

KEY=\u201dvaluewithspaces\u201d<\/p>\n

\u4e8c\u3001Shell\u53d8\u91cf<\/p>\n

Shell\u53d8\u91cf\u662f\u4e13\u95e8\u7528\u4e8e\u8bbe\u7f6e\u6216\u5b9a\u4e49\u5b83\u4eec\u7684Shell\u4e2d\u7684\u53d8\u91cf\u3002\u6bcf\u4f4dShelllinux\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u8def\u5f84<\/strong>\uff0c\u6bd4\u5982zsh\u548cbash\uff0c\u90fd\u6709\u4e00\u7ec4\u81ea\u5df1\u5185\u90e8\u7684Shell<\/p>\n

\u53d8\u91cf\u3002\u5b83\u4eec\u4e00\u822c\u7528\u4e8e\u8ddf\u8e2a\u4e34\u65f6\u6570\u636e\uff0c\u4f8b\u5982\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\uff0c\u800c\u7528\u6cd5\u5219\u4e0e\u73af\u5883\u53d8\u91cf\u76f8\u540c\u3002<\/p>\n

\u5047\u5982\u4f60\u60f3\u8ba9Shell\u53d8\u91cf\u4f5c\u4e3a\u5168\u5c40\u53d8\u91cf\u4f7f\u7528\uff0c\u53ef\u4ee5\u4f7f\u7528export\u6307\u4ee4\uff1a<\/p>\n

$exportMYVAR=<\/p>\n

echo<\/p>\n

$env|grepMYVARMYVAR=<\/p>\n

\u4e09\u3001\u5e38\u89c1\u7684\u73af\u5883\u53d8\u91cf\u4e0eShell\u53d8\u91cf<\/p>\n

\u4e00\u4e9b\u73af\u5883\u53d8\u91cf\u548cShell\u53d8\u91cf\u662f\u5341\u5206\u6709\u7528\u7684\uff0c\u800c\u4e14\u5e38\u5e38\u4f1a\u88ab\u5f15\u7528\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\uff0c\u4f60\u4e4b\u540e\u53ef\u80fd\u4f1a\u78b0\u5230\u7684\u73af\u5883\u53d8\u91cf\uff1a<\/p>\n

\u53d8\u91cf\u540d\u6db5\u4e49<\/p>\n

TERM\u8fd9\u6307\u5b9a\u8fd0\u884cShell\u65f6\u8981\u6a21\u62df\u7684\u7ec8\u7aef\u7c7b\u578b\u3002\u53ef\u4ee5\u9488\u5bf9\u4e0d\u540c\u7684\u64cd\u4f5c\u9700\u6c42\u6a21\u62df\u4e0d\u540c\u7684\u786c\u4ef6\u7ec8\u7aef\u3002\u4e0d\u8fc7\uff0c\u4f60\u4e00\u822c\u4e0d\u987b\u8981\u7ba1\u8fd9\u4e2a\u53d8\u91cf\u3002<\/p>\n

USER\u5f53\u524d\u767b\u5165\u7684\u7528\u6237<\/p>\n

PWD\u5f53\u524d\u7684\u5de5\u4f5c\u76ee\u5f55<\/p>\n

linux\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u8def\u5f84_linux\u73af\u5883\u53d8\u91cf\u8def\u5f84_linux\u8def\u5f84\u53d8\u91cf<\/p>\n

OLDPWD\u4e0a\u4e00\u4e2a\u5de5\u4f5c\u76ee\u5f55\uff0c\u8fd9\u4e2a\u53d8\u91cf\u7531Shell\u4fdd\u5b58\uff0c\u4fbf\u4e8e\u901a\u8fc7\u6267\u884ccd\u2013\u5207\u6362\u56de\u4e0a\u4e00\u4e2a\u5de5\u4f5c\u76ee\u5f55\u3002<\/p>\n

LS_COLORS\u8fd9\u5b9a\u4e49\u4e86ls\u6307\u4ee4\u7684\u989c\u8272\u8f93\u51fa\u4ee3\u7801\uff0c\u7528\u4e8e\u5411ls<\/p>\n

\u6307\u4ee4\u6dfb\u52a0\u989c\u8272\u8f93\u51fa\u3002\u8fd9\u4e00\u822c\u7528\u4e8e\u5206\u8fa8\u4e0d\u540c\u7684\u6587\u4ef6\u7c7b\u578b\u5e76\u4f7f\u7528\u6237\u5bf9\u6587\u4ef6\u7c7b\u578b\u7b49\u4fe1\u606f\u4e00\u76ee\u4e86\u7136\u3002<\/p>\n

MAIL\u5f53\u524d\u7528\u6237\u90ae\u7bb1\u7684\u8def\u5f84<\/p>\n

PATH\u7cfb\u7edf\u5728\u67e5\u627e\u6307\u4ee4\u65f6\u4f1a\u68c0\u6d4b\u7684\u76ee\u5f55\u5217\u8868\u3002\u5f53\u7528\u6237\u8f93\u5165\u4e00\u4e2a\u6307\u4ee4\u65f6\uff0c\u7cfb\u7edf\u5c06\u6309\u6b64\u76ee\u5f55\u5217\u8868\u7684\u6b21\u5e8f\u68c0\u6d4b\u76ee\u5f55\uff0c\u4ee5\u627e\u5bfb\u76f8\u5e94\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n

LANG\u5f53\u524d\u7684\u8bed\u8a00\u548c\u672c\u5730\u5316\u8bbe\u7f6e\uff0c\u5305\u62ec\u5b57\u7b26\u7f16\u7801\u3002<\/p>\n

HOME\u5f53\u524d\u7528\u6237\u7684\u4e3b\u76ee\u5f55<\/p>\n

_\u4e0a\u4e00\u4e2a\u88ab\u6267\u884c\u7684\u6307\u4ee4<\/p>\n

\u4e0d\u4ec5\u4ee5\u4e0a\u8fd9\u79cd\u73af\u5883\u53d8\u91cf\uff0c\u4f60\u4e5f\u53ef\u80fd\u4f1a\u65f6\u5e38\u9047\u89c1\u4ee5\u4e0b\u8fd9\u79cdShell\u53d8\u91cf:<\/p>\n

\u53d8\u91cf\u540d\u6db5\u4e49<\/p>\n

BASHOPTS\u6267\u884cbash\u65f6\u6240\u542f\u7528\u7684\u9009\u9879\u5217\u8868\uff0c\u8fd9\u5bf9\u4e8e\u786e\u5b9aShell\u73af\u5883\u662f\u5426\u4f9d\u7167\u9884\u671f\u7684\u5f62\u5f0f\u8fd0\u884c\u5f88\u6709\u5e2e\u52a9\u3002<\/p>\n

BASH_VERSION\u4eba\u7c7b\u53ef\u8bfb\u683c\u5f0f\u7684\u6b63\u5728\u6267\u884c\u7684bash\u7248\u672c<\/p>\n

BASH_VERSINFO\u673a\u5668\u53ef\u8bfb\u683c\u5f0f\u7684\u6b63\u5728\u6267\u884c\u7684bash\u7248\u672c<\/p>\n

COLUMNS\u7528\u4e8e\u8bbe\u7f6e\u52fe\u753b\u5230\u5c4f\u5e55\u4e0a\u7684\u8f93\u51fa\u4fe1\u606f\u7684\u5bbd\u7684\u5217\u6570<\/p>\n

DIRSTACKpushd\u548cpopd\u547d\u4ee4<\/a>\u53ef\u7528\u7684\u76ee\u5f55\u5806\u6808\u3002<\/p>\n

HISTFILESIZE\u50a8\u5b58\u5230\u6587\u4ef6\u4e2d\u7684\u547d\u4ee4\u5386\u53f2\u8bb0\u5f55\u7684\u884c\u6570\u3002\u9ed8\u8ba4\u4e3a~\/.bash_history\u6587\u4ef6\u7684\u884c\u6570\u3002<\/p>\n

HISTSIZE\u663e\u5b58\u4e2d\u5bb9\u8bb8\u50a8\u5b58\u7684\u547d\u4ee4\u5386\u53f2\u8bb0\u5f55\u7684\u884c\u6570\uff0c\u5373histroy\u547d\u4ee4\u6240\u80fd\u590d\u5370\u4e0b\u6765\u7684\u884c\u6570\u3002<\/p>\n

HOSTNAME\u8ba1\u7b97\u673a\u7684\u4e3b\u673a\u540d<\/p>\n

IFS\u5185\u90e8\u6570\u7ec4\u5206\u9694\u7b26\uff0c\u7528\u4e8e\u5206\u9694\u547d\u4ee4\u884c\u4e0a\u7684\u8f93\u5165\u3002\u9ed8\u8ba4\u4ee5\u7a7a\u683c\u4f5c\u4e3a\u5206\u9694\u7b26\u3002<\/p>\n

PS1\u5b9a\u4e49\u4e3b\u547d\u4ee4\u63d0\u793a\u7b26\u3002\u8fd9\u7528\u4e8e\u5b9a\u4e49\u542f\u52a8Shell\u4f1a\u8bdd\u65f6\u547d\u4ee4\u63d0\u793a\u7b26\u7684\u5916\u578b\u3002\u800cPS2\u7528\u4e8e\u7533\u660e\u8de8\u8d8a\u591a\u884c\u7684\u547d\u4ee4\u7684\u547d\u4ee4\u63d0\u793a\u7b26\u3002<\/p>\n

SHELLOPTS\u53ef\u4ee5\u7528set\u547d\u4ee4\u8bbe\u7f6e\u7684Shell\u9009\u9879\u3002<\/p>\n

UID\u5f53\u524d\u7528\u6237\u7684UID(\u7528\u6237ID)<\/p>\n

\u56db\u3001\u67e5\u770bShell\u53d8\u91cf\u4e0e\u73af\u5883\u53d8\u91cf<\/p>\n

\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u6709\u4ee5\u4e0b\u51e0\u79cd\u547d\u4ee4\u53ef\u4ee5\u8ba9\u4f60\u67e5\u770b\u73af\u5883\u53d8\u91cf\uff1a<\/p>\n

env\u2014\u8be5\u547d\u4ee4\u53ef\u4ee5\u8ba9\u4f60\u5728\u81ea\u5b9a\u4e49\u7684\u73af\u5883\u4e2d\u8fd0\u884c\u7a0b\u5e8f\uff0c\u4f46\u662f\u4e0d\u987b\u8981\u6539\u53d8\u5f53\u524d\u7684\u73af\u5883\u3002\u5f53\u4e0d\u5e26\u53c2\u6570\u4f7f\u7528env\u547d\u4ee4\u65f6\uff0c\u5b83\u4f1a\u590d\u5370\u51fa\u5f53\u524d\u7684\u73af\u5883\u53d8\u91cf\u5217\u8868\u3002<\/p>\n

printenv\u2014\u53ef\u4ee5\u590d\u5370\u51fa\u6240\u6709\u7684\u6216\u5219\u6307\u5b9a\u7684\u73af\u5883\u53d8\u91cf\u3002<\/p>\n

set\u2014\u8be5\u547d\u4ee4\u53ef\u4ee5\u8bbe\u7f6e\u6216\u5219\u5220\u6389Shell\u53d8\u91cf\u3002\u5f53\u4e0d\u5e26\u53c2\u6570\u4f7f\u7528set\u547d\u4ee4\u65f6\uff0c\u5b83\u5c06\u590d\u5370\u51fa\u5305\u62ec\u73af\u5883\u53d8\u91cf\u4e0eShell\u53d8\u91cf\u5728\u5185\u7684\u6240\u6709\u53d8\u91cf\u4ee5\u53ca<\/p>\n

Shell\u51fd\u6570\u7684\u5217\u8868\u3002<\/p>\n

linux\u8def\u5f84\u53d8\u91cf_linux\u73af\u5883\u53d8\u91cf\u8def\u5f84_linux\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u8def\u5f84<\/p>\n

\u9ed8\u8ba4\u72b6\u6001\u4e0b\uff0cenv\u548cprintenv\u7684\u529f\u80fd\u662f\u5b8c\u5168\u76f8\u540c\u7684\uff1a<\/p>\n

$printenv<\/p>\n

SSH_CONNECTION=10.0.2.23718210.0.2.1522<\/p>\n

LESSCLOSE=\/usr\/bin\/lesspipe%s%s<\/p>\n

LANG=C.UTF-8<\/p>\n

XDG_SESSION_ID=5<\/p>\n

USER=Alvin<\/p>\n

MYVAR=<\/p>\n

PWD=\/home\/Alvin<\/p>\n

HOME=\/home\/Alvin<\/p>\n

SSH_CLIENT=10.0.2.23718222<\/p>\n

XDG_DATA_DIRS=\/usr\/local\/share:\/usr\/share:\/var\/lib\/snapd\/desktop<\/p>\n

SSH_TTY=\/dev\/pts\/0<\/p>\n

MAIL=\/var\/mail\/Alvin<\/p>\n

TERM=xterm-256color<\/p>\n

SHELL=\/bin\/bash<\/p>\n

SHLVL=1<\/p>\n

LOGNAME=Alvin<\/p>\n

XDG_RUNTIME_DIR=\/run\/user\/1000<\/p>\n

PATH=\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/<\/p>\n

sbin:\/bin:\/usr\/games:\/usr\/local\/games:\/snap\/bin<\/p>\n

LESSOPEN=|\/usr\/bin\/lesspipe%s<\/p>\n

_=\/usr\/bin\/printenv<\/p>\n

\u53ea\u6709\u5728\u66f4\u5177\u4f53\u7684\u529f\u80fd\u4e0a\u80fd\u591f\u5f70\u663e\u51faenv\u547d\u4ee4\u4e0eprintenv\u547d\u4ee4\u7684\u533a\u522b\u3002\u8bf8\u5982\uff0c\u4f7f\u7528printenv\u547d\u4ee4\uff0c\u4f60\u53ef\u4ee5\u6073\u6c42\u5355\u4e2a\u53d8\u91cf\u7684\u503c\uff1a<\/p>\n

$printenvSHELL<\/p>\n

\/bin\/bash<\/p>\n

$printenvHOME<\/p>\n

\/home\/Alvin<\/p>\n

$printenvMYVAR<\/p>\n

env\u547d\u4ee4\u53ef\u901a\u8fc7\u5c06\u4e00\u7ec4\u53d8\u91cf\u4f20\u9012\u7ed9\u547d\u4ee4\u6765\u66f4\u6539\u7a0b\u5e8f\u8fd0\u884c\u7684\u73af\u5883\uff1a<\/p>\n

envMYVAR=command_to_runcommand_options<\/p>\n

printenv\u4e0eenv\u547d\u4ee4\u53ea\u80fd\u590d\u5370\u51fa\u73af\u5883\u53d8\u91cf\uff0c\u800c\u5047\u5982\u4f60\u60f3\u590d\u5370\u51fa\u6240\u6709\u53d8\u91cf\u6216\u5219Shell\u51fd\u6570\u7684\u5217\u8868\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528set\u6307\u4ee4\u3002<\/p>\n

$set<\/p>\n

BASH=\/bin\/bash<\/p>\n

BASHOPTS=checkwinsize:cmdhist:complete_fullquote:expand_aliases:extglob:extquote:force_fignore:histappend:interactive_comments:login_shell:progcomp:promptvars:sourcepath<\/p>\n

BASH_ALIASES=()<\/p>\n

BASH_ARGC=()<\/p>\n

BASH_ARGV=()<\/p>\n

BASH_CMDS=()<\/p>\n

BASH_COMPLETION_VERSINFO=([0]=\u201d2\u2033[1]=\u201d8\u2033)<\/p>\n

BASH_LINENO=()<\/p>\n

BASH_SOURCE=()<\/p>\n

BASH_VERSINFO=([0]=\u201d4\u2033[1]=\u201d4\u2033[2]=\u201d20\u2033[3]=\u201d1\u2033<\/p>\n

[4]=\u201drelease\u201d[5]=\u201dx86_64-pc-linux-gnu\u201d)<\/p>\n

BASH_VERSION=\u20194.4.20(1)-release\u2019<\/p>\n

COLUMNS=140<\/p>\n

DIRSTACK=()<\/p>\n

EUID=1000<\/p>\n

GROUPS=()<\/p>\n

HISTCONTROL=ignoreboth<\/p>\n

HISTFILE=\/home\/alvin\/.bash_history<\/p>\n

HISTFILESIZE=2000<\/p>\n

HISTSIZE=1000HOME=\/home\/alvinHOSTNAME=ubuntu-bionic<\/p>\n

HOSTTYPE=x86_64IFS=$\u2019tn\u2019LANG=C.UTF-8<\/p>\n

LESSCLOSE=\u2019\/usr\/bin\/lesspipe%s%s\u2019<\/p>\n

LESSOPEN=\u2019|\/usr\/bin\/lesspipe%s\u2019<\/p>\n

LINES=35LOGNAME=Alvin<\/p>\n

\u2026..<\/p>\n

\u8be5\u547d\u4ee4\u5c06\u663e\u793a\u4e00\u4e2a\u5305\u542b\u6240\u6709\u53d8\u91cf\u7684\u5927\u5217\u8868\uff0c\u56e0\u800c\u4f60\u53ef\u80fd\u4f1a\u5e0c\u671b\u5c06\u8f93\u51fa\u4f20\u9012\u7ed9less\u547d\u4ee4\u3002<\/p>\n

$set|less<\/p>\n

\u4e94\u3001\u8bbe\u7f6eShell\u53d8\u91cf\u4e0e\u73af\u5883\u53d8\u91cf<\/p>\n

Linux\u7cfb\u7edf\u4e2d\u53ef\u4ee5\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u7684\u547d\u4ee4\u6709\u4ee5\u4e0b\u51e0\u79cd\uff1a<\/p>\n

set\u2014\u8be5\u547d\u4ee4\u53ef\u4ee5\u8bbe\u7f6e\u6216\u5219\u53d6\u6d88\u8bbe\u7f6eShell\u53d8\u91cf\u3002\u5f53\u4e0d\u5e26\u53c2\u6570\u4f7f\u7528set\u547d\u4ee4\u65f6\uff0c\u5b83\u5c06\u590d\u5370\u51fa\u5305\u62ec\u73af\u5883\u53d8\u91cf\u4e0eShell\u53d8\u91cf\u5728\u5185\u7684\u6240\u6709\u53d8\u91cf\u4ee5\u53ca<\/p>\n

Shell\u51fd\u6570\u7684\u5217\u8868\u3002<\/p>\n

unset\u2014\u8be5\u547d\u4ee4\u53ef\u4ee5\u5220\u6389Shell\u53d8\u91cf\u4ee5\u53ca\u73af\u5883\u53d8\u91cf\u3002<\/p>\n

export\u2014\u8be5\u547d\u4ee4\u53ef\u4ee5\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u3002<\/p>\n

\u4e3a\u4e86\u66f4\u597d\u5730\u7406\u89e3Shell\u53d8\u91cf\u548c\u73af\u5883\u53d8\u91cf\u4e4b\u95f4\u7684\u533a\u522b\uff0c\u6211\u4eec\u5148\u4ece\u8bbe\u7f6eShell\u53d8\u91cf\u5f00\u59cb\u8bb2\uff0c\u4e4b\u540e\u518d\u8bb2\u73af\u5883\u53d8\u91cf\u3002<\/p>\n

\u5148\u4ece\u5728\u5f53\u524d\u4f1a\u8bdd\u4e2d\u5b9a\u4e49\u4e00\u4e2aShell\u53d8\u91cf\u5f00\u59cb\uff1a<\/p>\n

$MYVAR=lxlinux<\/p>\n

\u4f60\u53ef\u4ee5\u7528echo$MYVAR\u6765\u9a8c\u8bc1\u53d8\u91cf\u662f\u5426\u5df2\u8bbe\u7f6e\uff1a<\/p>\n

echoMYVAR<\/p>\n

lxlinux<\/p>\n

\u4f7f\u7528printenv\u547d\u4ee4\u68c0\u9a8c\u8be5\u53d8\u91cf\u662f\u5426\u4e3a\u73af\u5883\u53d8\u91cf\uff1a<\/p>\n

$printenvMYVAR<\/p>\n

\u6ca1\u6709\u8f93\u51fa\u8fd4\u56de\uff0c\u8fd9\u5c31\u610f\u5473\u7740MYVAR\u53d8\u91cf\u5e76\u4e0d\u662f\u73af\u5883\u53d8\u91cf\u3002<\/p>\n

export\u547d\u4ee4\u53ef\u4ee5\u62ff\u6765\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u3002\u8981\u521b\u5efa\u73af\u5883\u53d8\u91cf\uff0c\u53ea\u9700\u7528export\u547d\u4ee4\u5c06Shell\u53d8\u91cf\u5bfc\u5165\u4e3a\u73af\u5883\u53d8\u91cf\uff1a<\/p>\n

$exportMYVAR<\/p>\n

\u4f60\u53ef\u4ee5\u7528\u4ee5\u4e0b\u53e5\u5b50\u68c0\u9a8c\uff1a<\/p>\n

$printenvMYVARlxlinux<\/p>\n

\u5176\u5b9e\uff0c\u4f60\u4e5f\u53ef\u4ee5\u53ea\u7528\u4e00\u884c\u4ee3\u7801\u6765\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff1a<\/p>\n

$exportMYNEWVAR=\u201dMyNewVariable\u201d<\/p>\n

\u7136\u800c\u4ee5\u8fd9\u4e9b\u65b9\u6cd5\u521b\u5efa\u7684\u73af\u5883\u53d8\u91cf\u53ea\u80fd\u7528\u4e8e\u5f53\u524d\u4f1a\u8bdd\uff0c\u5047\u5982\u4f60\u6253\u5f00\u4e00\u4e2a\u65b0\u7684Shell\u4f1a\u8bdd\uff0c\u6216\u5219\u9000\u51fa\u767b\u5165\uff0c\u6240\u6709\u7684\u53d8\u91cf\u90fd\u5c06\u4f1a\u9057\u5931\u3002<\/p>\n

linux\u8def\u5f84\u53d8\u91cf_linux\u73af\u5883\u53d8\u91cf\u8def\u5f84_linux\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u8def\u5f84<\/p>\n

\u6211\u4eec\u4e5f\u53ef\u4ee5\u5c06\u73af\u5883\u53d8\u91cf\u8fd8\u539f\u4e3aShell\u53d8\u91cf\uff0c\u6216\u5219\u5c06\u5176\u5b8c\u5168\u5220\u6389\uff1a<\/p>\n

MYVAR\u53d8\u91cf\u88ab\u5b9a\u4e49\u4e3a\u73af\u5883\u53d8\u91cf\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u8f93\u5165\u4ee5\u4e0b\u4ee3\u7801\u5c06\u5176\u8fd8\u539f\u4e3aShell\u53d8\u91cf:<\/p>\n

$export-nMYVAR<\/p>\n

\u8fd9\u6837\uff0cMYVAR\u53d8\u91cf\u5c31\u4e0d\u518d\u662f\u73af\u5883\u53d8\u91cf\u4e86\uff0c\u4f46\u4ecd\u7136\u8fd8\u662fShell\u53d8\u91cf\u3002<\/p>\n

\u65e0\u8bba\u662fShell\u53d8\u91cf\u8fd8\u662f\u73af\u5883\u53d8\u91cf\uff0c\u60f3\u8981\u5b8c\u5168\u5220\u6389\u53d8\u91cf\uff0c\u90fd\u53ef\u4ee5\u4f7f\u7528unset\u547d\u4ee4\u6765\u5220\u6389\uff1a<\/p>\n

$unsetMYVAR<\/p>\n

\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u53e5\u5b50\u6765\u9a8c\u8bc1MYVAR\u53d8\u91cf\u65e9\u5df2\u5220\u6389\uff1a<\/p>\n

echoMYVAR<\/p>\n

\u56e0\u4e3a\u53d8\u91cf\u65e9\u5df2\u5220\u6389\u4e86\uff0c\u6240\u4ee5\u6ca1\u6709\u4efb\u4f55\u8fd4\u56de\u3002<\/p>\n

\u516d\u3001\u73af\u5883\u53d8\u91cf\u7684\u6301\u4e45\u5316<\/p>\n

\u8bb8\u591a\u7a0b\u5e8f\u90fd\u987b\u8981\u4f7f\u7528\u73af\u5883\u53d8\u91cf\u6765\u51b3\u5b9a\u5177\u4f53\u7684\u6267\u884c\u65b9\u6cd5\uff0c\u5e76\u4e14\uff0c\u6211\u4eec\u5e76\u4e0d\u5e0c\u671b\u6bcf\u6b21\u542f\u52a8\u65b0\u7684Shell<\/p>\n

\u4f1a\u8bdd\u65f6\u90fd\u5fc5\u987b\u91cd\u65b0\u8bbe\u7f6e\u91cd\u8981\u7684\u53d8\u91cf\uff0c\u56e0\u800c\u6211\u4eec\u987b\u8981\u5c06\u91cd\u8981\u7684\u73af\u5883\u53d8\u91cf\u5199\u5165\u914d\u7f6e\u6587\u4ef6\u4e2d\u3002<\/p>\n

Shell\u4f1a\u8bdd\u6709\u4e0d\u540c\u7684\u542f\u52a8\u65b9\u6cd5\uff0c\u4f8b\u5982\uff0c\u8054\u63a5\u5230\u7ec8\u7aef\u7684\u4ea4\u4e92\u5f0fShell\u4e0e\u672a\u8054\u63a5\u5230\u7ec8\u7aef\u7684\u975e\u4ea4\u4e92\u5f0fShell\uff0c\u8fd8\u6709\u767b\u9646\u5f0fShell\u4e0e\u975e\u767b\u9646\u5f0f<\/p>\n

Shelllinux\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u8def\u5f84<\/strong>\uff0c\u800cbashShell\u4f1a\u4f9d\u7167\u4f1a\u8bdd\u4e0d\u540c\u7684\u542f\u52a8\u65b9\u6cd5\u800c\u8bfb\u53d6\u4e0d\u540c\u7684\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n

\u7136\u800c\uff0c\u5728\u5927\u591a\u6570Linux\u53d1\u884c\u7248\u4e2d\uff0c\u5f53\u4f60\u542f\u52a8\u4e00\u4e2a\u65b0\u7684Shell\u4f1a\u8bdd\u65f6\uff0c\u901a\u5e38\u5c31\u4f1a\u4ece\u4ee5\u4e0b\u6587\u4ef6\u4e2d\u8bfb\u53d6\u73af\u5883\u53d8\u91cf:<\/p>\n

\/etc\/environment\u2014\u4f7f\u7528\u6b64\u6587\u4ef6\u6765\u8bbe\u7f6e\u7cfb\u7edf\u8303\u56f4\u5185\u53ef\u7528\u7684\u73af\u5883\u53d8\u91cf\u3002<\/p>\n

\/etc\/profile\u2014\u6bcf\u5f53bash\u767b\u9646Shell\u65f6\uff0c\u5c31\u4f1a\u52a0\u8f7d\u6b64\u6587\u4ef6\u4e2d\u8bbe\u7f6e\u7684\u53d8\u91cf\u3002<\/p>\n

~\/.bashrc\u2014\u6bcf\u4e2a\u7528\u6237\u7279\u5b9a\u7684Shell\u914d\u7f6e\u6587\u4ef6\u3002\u8bf8\u5982\uff0c\u5047\u5982\u4f60\u4f7f\u7528\u7684\u662fBash\uff0c\u5c31\u53ef\u4ee5\u5728\u5176\u4e2d\u7533\u660e\u53d8\u91cf\u3002<\/p>\n

\u5018\u82e5\u8981\u5c06\u65b0\u7684\u73af\u5883\u53d8\u91cf\u52a0\u8f7d\u5230\u5f53\u524d\u7684Shell\u4f1a\u8bdd\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528source\u547d\u4ee4\uff1a<\/p>\n

$source~\/.bashrc<\/p>\n

\u5047\u5982\u4f60\u60f3\u8981\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u4f60\u5c31\u53ef\u4ee5\u8003\u8651\u5c06\u5176\u6dfb\u52a0\u5230\/etc\/profile\u3001\/etc\/bash.bashrc\u6216\/etc\/environment<\/p>\n

\u6587\u4ef6\u4e2d\u3002<\/p>\n

\u63a8\u8bba<\/p>\n

\u4ee5\u4e0a\u5c31\u662f\u5c0f\u7f16\u660e\u5929\u4e3a\u4f60\u4eec\u5206\u4eab\u7684\u5173\u4e8eLinux\u7cfb\u7edf\u4e2d\u7684\u73af\u5883\u53d8\u91cf\u8be5\u600e\u4e48\u8bbe\u7f6e\u4e0e\u67e5\u770b\u7684\u6587\u7ae0\uff0c\u5728\u672c\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u4e86\u89e3\u4e86\u4e00\u4e9b\u5e38\u89c1\u7684\u73af\u5883\u53d8\u91cf\u548cShell<\/p>\n

\u53d8\u91cf\uff0c\u4e5f\u5b66\u4e60\u4e86\u600e\u6837\u8bbe\u7f6e\u548c\u67e5\u770b\u8fd9\u79cd\u53d8\u91cf\uff0c\u867d\u7136\u8fd9\u79cd\u53d8\u91cf\u59cb\u7ec8\u90fd\u5728\u6211\u4eec\u7684Shell<\/p>\n

\u4f1a\u8bdd\u4e2d\uff0c\u5e76\u4e14\u5bf9\u8bb8\u591a\u7a0b\u5e8f\u90fd\u5f88\u6709\u7528\uff0c\u6709\u597d\u591a\u5e38\u89c1\u7684\u573a\u666f\u5c31\u4f1a\u5f15\u7528\u5230\u8fd9\u79cd\u53d8\u91cf\u3002\u5e0c\u671b\u8fd9\u5bf9\u4f60\u7684\u5de5\u4f5c\u4e5f\u6709\u5e2e\u52a9\u3002\u60f3\u8981\u4e86\u89e3\u66f4\u591aLinux\u76f8\u5173\u77e5\u8bc6\u8bb0\u5f97\u5173\u6ce8\u8fbe\u5185Linux\u57f9\u8bad\u5b98\u7f51\uff0c\u6700\u540e\u795d\u798f\u7537\u5b50\u4f34\u4eec\u5de5\u4f5c\u987a\u5229\u3002<\/p>\n

\u539f\u521b\u826f\u8bb8\u826f\u8bb8Linux<\/p>\n","protected":false},"excerpt":{"rendered":"

\u53d8\u91cf\uff0c\u8be5\u5982\u4f55\u8bbe\u7f6e\u548c\u67e5\u770b\u8fd9\u4e24\u79cd\u53d8\u91cf\u5462?\u7cfb\u7edf\u4e2d\uff0c\u6709\u4ee5\u4e0b\u51e0\u79cd\u547d\u4ee4\u53ef\u4ee5\u8ba9\u4f60\u67e5\u770b\u73af\u5883\u53d8\u91cf\uff1a\u7cfb\u7edf\u4e2d\u53ef\u4ee5\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u7684\u547d\u4ee4\u6709\u4ee5\u4e0b\u51e0\u79cd\uff1a\u8be5\u547d\u4ee4\u53ef\u4ee5\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u3002\u4f1a\u8bdd\u65f6\u90fd\u5fc5\u987b\u91cd\u65b0\u8bbe\u7f6e\u91cd\u8981\u7684\u53d8\u91cf\uff0c\u56e0\u6b64\u6211\u4eec\u9700\u8981\u5c06\u91cd\u8981\u7684\u73af\u5883\u53d8\u91cf\u5199\u5165\u914d\u7f6e\u6587\u4ef6\u4e2d\u3002\u4f7f\u7528\u6b64\u6587\u4ef6\u6765\u8bbe\u7f6e\u7cfb\u7edf\u8303\u56f4\u5185\u53ef\u7528\u7684\u73af\u5883\u53d8\u91cf\u3002<\/p>\n","protected":false},"author":1,"featured_media":295368,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[988],"tags":[1001,5387,4177,1006,4215],"class_list":["post-295367","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tougao","tag-lxt","tag-sbl","tag-zkff","tag-hjbl","tag-szff"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/295367","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=295367"}],"version-history":[{"count":0,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/295367\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/295368"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=295367"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=295367"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=295367"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}