Printing Linux Environment using C Program
Linux provides each running program with an environment. The environment is a collection of variable/value pairs. Both environment variable names and their values are character strings. By convention, environment variable names are spelled in all capital letters. You’re probably familiar with several common environment variables already.
USER contains your username.
HOME contains the path to your home directory.
PATH contains a colon-separated list of directories through which Linux searches for commands you invoke.
DISPLAY contains the name and display number of the X Window server on which windows from graphical X Window programs will appear.
//Printing the Execution Environment
/* The ENVIRON variable contains the environment. */
extern char** environ;
int main ()
for (var = environ; *var != NULL; ++var)
printf (“%s\n”, *var);