Write a c program to print all environment variables in Linux using c programming. Environmental variables are stored in system. It provide a way to influence the behavior of software program on the system.

c program to print all environment variables In Linux

output:

( here is some output )

The environment variables are strings that represent key-value pairs. For example HOME is Linux environmental variable. The HOME variable represents linux user’s home directory.

Look at the below PATH variable.

From PATH and its value we can notice that a environmental variable can contain more than one value by using “:”

  • We can also check the value of Linux environmental variable from shell command echo.

print all environment variables in Linux using c programming