如何列出包括 LD_LIBRARY_PATH 在内的所有 Linux 环境变量
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21122303/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to list all Linux environment variables including LD_LIBRARY_PATH
提问by Michael harris
How to list all the environment variables in Linux?
如何列出Linux中的所有环境变量?
When I type the command env
or printenv
it gives me lots of variables, but some variables like LD_LIBRARY_PATH
and PKG_CONFIG
don't show up in this list.
当我输入命令时env
,printenv
它会给我很多变量,但有些变量喜欢LD_LIBRARY_PATH
和PKG_CONFIG
没有出现在这个列表中。
I want to type a command that list all the environment variables including this variables (LD_LIBRARY_PATH
and PKG_CONFIG
)
我想输入一个命令,列出所有环境变量,包括这个变量(LD_LIBRARY_PATH
和PKG_CONFIG
)
采纳答案by Maxim Egorushkin
env
does list all environment variables.
env
确实列出了所有环境变量。
If LD_LIBRARY_PATH
is not there, then that variable was not declared; or was declared but not export
ed, so that child processes do not inherit it.
如果LD_LIBRARY_PATH
不存在,则未声明该变量;或已声明但未export
ed,因此子进程不会继承它。
If you are setting LD_LIBRARY_PATH
in your shell start-up files, like .bash_profile
or .bashrc
make sure it is exported:
如果你LD_LIBRARY_PATH
在你的 shell 启动文件中设置,像.bash_profile
或.bashrc
确保它被导出:
export LD_LIBRARY_PATH
回答by sager89
try
尝试
export LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH}
This will modify the variable.
这将修改变量。
To print it, type: echo $LD_LIBRARY_PATH
and it should show the above value.
要打印它,请键入:echo $LD_LIBRARY_PATH
它应该显示上述值。
If you're seeing nothing when you print that, then the variable might not be set.
如果您在打印时什么也没看到,则可能未设置该变量。
回答by BMW
The question in fact is a good question. when run env
or printenv
, the output will be the system environment, but LD_LIBRARY_PATH is not belong to.
这个问题其实是个好问题。运行env
或 时printenv
,输出将是系统环境,但 LD_LIBRARY_PATH 不属于。
For example, if you set a=1
, you can't show it by env
. Same as LD_LIBRARY_PATH, it is used by ld.so only(ld. so – this little program that starts all your applications)
例如,如果您设置了a=1
,则无法通过 显示它env
。与 LD_LIBRARY_PATH 相同,它仅由 ld.so 使用(ld.so - 这个启动所有应用程序的小程序)