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.
Assuming you want the variables actually used by some process running a command, you could use ltrace and look for calls to getenv:
Of course, the argument to
getenvcan be computed (so you cannot really predict it).However, some (old or strange) applications might use the
environglobal, or the third optional argument tomain; and some applications even change their environment using putenv, setenv orunsetenv(all 3 being the libc functions, not the shell builtin).but
xprintidleis mostly interacting with the Xorg server. I’m surprised you are expecting it to use many environment variables (exceptDISPLAY).