In a Linux environment (in my case XUbuntu), is there a way to find out which environment variables are accessed by a command which is run from the console?
It must be possible to find out about these variables, as someone has to provide the values to the program. But is there some default method to do this?
The program in question here is xprintidle.
To Check if an Environment Variable ExistsSelect Start > All Programs > Accessories > Command Prompt. In the command window that opens, enter echo %VARIABLE%. Replace VARIABLE with the name of the environment variable.
You can open a Command Prompt, type set , and press Enter to display all current environment variables on your PC. You can open PowerShell, type Get-ChildItem Env: , and press Enter to display all current environment variables on your PC.
You can view all environment variables set on your system with the env command.
Assuming you want the variables actually used by some process running a command, you could use ltrace and look for calls to getenv:
$ ltrace -e getenv ./your_program
Of course, the argument to getenv
can be computed (so you cannot really predict it).
However, some (old or strange) applications might use the environ
global, or the third optional argument to main
; and some applications even change their environment using putenv, setenv or unsetenv
(all 3 being the libc functions, not the shell builtin).
but xprintidle
is mostly interacting with the Xorg server. I'm surprised you are expecting it to use many environment variables (except DISPLAY
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With