如何列出所有Linux环境变量,包括LD_LIBRARY_PATH

时间:2022-01-08 22:41:59

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)

3 个解决方案

#1


6  

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 exported, so that child processes do not inherit it.

如果不存在LD_LIBRARY_PATH,则不声明该变量;或者已声明但未导出,因此子进程不会继承它。

If you are setting LD_LIBRARY_PATH in your shell start-up files, like .bash_profile or .bashrc make sure it is exported:

如果要在shell启动文件中设置LD_LIBRARY_PATH,例如.bash_profile或.bashrc,请确保将其导出:

export LD_LIBRARY_PATH

#2


8  

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.

如果在打印时没有看到任何内容,则可能未设置该变量。

#3


1  

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。所以 - 这个启动所有应用程序的小程序)

#1


6  

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 exported, so that child processes do not inherit it.

如果不存在LD_LIBRARY_PATH,则不声明该变量;或者已声明但未导出,因此子进程不会继承它。

If you are setting LD_LIBRARY_PATH in your shell start-up files, like .bash_profile or .bashrc make sure it is exported:

如果要在shell启动文件中设置LD_LIBRARY_PATH,例如.bash_profile或.bashrc,请确保将其导出:

export LD_LIBRARY_PATH

#2


8  

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.

如果在打印时没有看到任何内容,则可能未设置该变量。

#3


1  

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。所以 - 这个启动所有应用程序的小程序)