Michael harris
Michael harris

Reputation: 996

How to list all Linux environment variables including LD_LIBRARY_PATH

How to list all the environment variables in 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.

I want to type a command that list all the environment variables including this variables (LD_LIBRARY_PATH and PKG_CONFIG)

Upvotes: 18

Views: 77576

Answers (3)

sager89
sager89

Reputation: 980

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.

If you're seeing nothing when you print that, then the variable might not be set.

Upvotes: 12

Maxim Egorushkin
Maxim Egorushkin

Reputation: 136238

env does list all environment variables.

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.

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

export LD_LIBRARY_PATH

Upvotes: 13

BMW
BMW

Reputation: 45243

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.

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)

Upvotes: 2

Related Questions