# environ(7) - man - phpMan

[ENVIRON(7)](https://www.chedong.com/phpMan.php/man/ENVIRON/7/markdown)                            Linux Programmer's Manual                           [ENVIRON(7)](https://www.chedong.com/phpMan.php/man/ENVIRON/7/markdown)



## NAME
       environ - user environment

## SYNOPSIS
       **extern** **char** ******_environ_**;**

## DESCRIPTION
       The variable _environ_ points to an array of pointers to strings called the "environment".  The
       last pointer in this array has the value NULL.  (This variable must be declared in  the  user
       program,  but is declared in the header file _<unistd.h>_ if the ___**GNU**___**SOURCE** feature test macro
       is defined.)  This array of strings is made available to the process by the [**exec**(3)](https://www.chedong.com/phpMan.php/man/exec/3/markdown) call that
       started  the process.  When a child process is created via [**fork**(2)](https://www.chedong.com/phpMan.php/man/fork/2/markdown), it inherits a _copy_ of its
       parent's environment.

       By convention the strings in _environ_ have the form "_name_**=**_value_".  Common examples are:

       **USER**   The name of the logged-in user (used by some BSD-derived programs).

       **LOGNAME**
              The name of the logged-in user (used by some System-V derived programs).

       **HOME**   A user's login directory, set by [**login**(1)](https://www.chedong.com/phpMan.php/man/login/1/markdown) from the password file [**passwd**(5)](https://www.chedong.com/phpMan.php/man/passwd/5/markdown).

       **LANG**   The name of a locale to use for locale categories when not  overridden  by  **LC**___**ALL**  or
              more specific environment variables such as **LC**___**COLLATE**, **LC**___**CTYPE**, **LC**___**MESSAGES**, **LC**___**MON**‐‐
              **ETARY**, **LC**___**NUMERIC**, and **LC**___**TIME** (see [**locale**(7)](https://www.chedong.com/phpMan.php/man/locale/7/markdown) for further details of the **LC**___***** environ‐
              ment variables).

       **PATH**   The sequence of directory prefixes that [**sh**(1)](https://www.chedong.com/phpMan.php/man/sh/1/markdown) and many other programs apply in search‐
              ing for a file known by an incomplete pathname.  The prefixes are  separated  by  '**:**'.
              (Similarly one has **CDPATH** used by some shells to find the target of a change directory
              command, **MANPATH** used by [**man**(1)](https://www.chedong.com/phpMan.php/man/man/1/markdown) to find manual pages, and so on)

       **PWD**    The current working directory.  Set by some shells.

       **SHELL**  The pathname of the user's login shell.

       **TERM**   The terminal type for which output is to be prepared.

       **PAGER**  The user's preferred utility to display text files.

       **EDITOR**/**VISUAL**
              The user's preferred utility to edit text files.

       Names may be placed in the shell's environment by the _export_ command  in  [**sh**(1)](https://www.chedong.com/phpMan.php/man/sh/1/markdown),  or  by  the
       _setenv_ command if you use [**csh**(1)](https://www.chedong.com/phpMan.php/man/csh/1/markdown).

       The  initial  environment of the shell is populated in various ways, such as definitions from
       _/etc/environment_ that are processed by **pam**___**[env**(8)](https://www.chedong.com/phpMan.php/man/env/8/markdown) for all users at  login  time  (on  systems
       that  employ [**pam**(8)](https://www.chedong.com/phpMan.php/man/pam/8/markdown)).  In addition, various shell initialization scripts, such as the system-
       wide _/etc/profile_ script and per-user initializations script may include  commands  that  add
       variables  to  the  shell's  environment; see the manual page of your preferred shell for de‐
       tails.

       Bourne-style shells support the syntax

           NAME=value command

       to create an environment variable definition only in the scope of the process  that  executes
       _command_.  Multiple variable definitions, separated by white space, may precede _command_.

       Arguments  may also be placed in the environment at the point of an [**exec**(3)](https://www.chedong.com/phpMan.php/man/exec/3/markdown).  A C program can
       manipulate its environment using the  functions  [**getenv**(3)](https://www.chedong.com/phpMan.php/man/getenv/3/markdown),  [**putenv**(3)](https://www.chedong.com/phpMan.php/man/putenv/3/markdown),  [**setenv**(3)](https://www.chedong.com/phpMan.php/man/setenv/3/markdown),  and  **un**‐‐
       [**setenv**(3)](https://www.chedong.com/phpMan.php/man/setenv/3/markdown).

       Note that the behavior of many programs and library routines is influenced by the presence or
       value of certain environment variables.  Examples include the following:

       *  The variables **LANG**, **LANGUAGE**, **NLSPATH**, **LOCPATH**, **LC**___**ALL**, **LC**___**MESSAGES**, and so  on  influence
          locale handling; see [**catopen**(3)](https://www.chedong.com/phpMan.php/man/catopen/3/markdown), [**gettext**(3)](https://www.chedong.com/phpMan.php/man/gettext/3/markdown), and [**locale**(7)](https://www.chedong.com/phpMan.php/man/locale/7/markdown).

       *  **TMPDIR**  influences  the path prefix of names created by [**tempnam**(3)](https://www.chedong.com/phpMan.php/man/tempnam/3/markdown) and other routines, and
          the temporary directory used by [**sort**(1)](https://www.chedong.com/phpMan.php/man/sort/1/markdown) and other programs.

       *  **LD**___**LIBRARY**___**PATH**, **LD**___**PRELOAD**, and other **LD**___***** variables influence the behavior  of  the  dy‐
          namic loader/linker.

       *  **POSIXLY**___**CORRECT**  makes  certain  programs and library routines follow the prescriptions of
          POSIX.

       *  The behavior of [**malloc**(3)](https://www.chedong.com/phpMan.php/man/malloc/3/markdown) is influenced by **MALLOC**___***** variables.

       *  The variable **HOSTALIASES** gives the name of a file containing aliases to be used with **geth**‐‐
          [**ostbyname**(3)](https://www.chedong.com/phpMan.php/man/ostbyname/3/markdown).

       *  **TZ** and **TZDIR** give timezone information used by [**tzset**(3)](https://www.chedong.com/phpMan.php/man/tzset/3/markdown) and through that by functions like
          [**ctime**(3)](https://www.chedong.com/phpMan.php/man/ctime/3/markdown), [**localtime**(3)](https://www.chedong.com/phpMan.php/man/localtime/3/markdown), [**mktime**(3)](https://www.chedong.com/phpMan.php/man/mktime/3/markdown), [**strftime**(3)](https://www.chedong.com/phpMan.php/man/strftime/3/markdown).  See also [**tzselect**(8)](https://www.chedong.com/phpMan.php/man/tzselect/8/markdown).

       *  **TERMCAP** gives information on how to address a given terminal (or gives the name of a  file
          containing such information).

       *  **COLUMNS**  and **LINES** tell applications about the window size, possibly overriding the actual
          size.

       *  **PRINTER** or **LPDEST** may specify the desired printer to use.  See [**lpr**(1)](https://www.chedong.com/phpMan.php/man/lpr/1/markdown).

## NOTES
       The [**prctl**(2)](https://www.chedong.com/phpMan.php/man/prctl/2/markdown) **PR**___**SET**___**MM**___**ENV**___**START** and **PR**___**SET**___**MM**___**ENV**___**END** operations can be used to control  the
       location of the process's environment.

## BUGS
       Clearly  there is a security risk here.  Many a system command has been tricked into mischief
       by a user who specified unusual values for **IFS** or **LD**___**LIBRARY**___**PATH**.

       There is also the risk of name space pollution.  Programs like _make_ and _autoconf_ allow  over‐
       riding  of  default  utility names from the environment with similarly named variables in all
       caps.  Thus one uses **CC** to select the desired C compiler (and similarly **MAKE**, **AR**, **AS**, **FC**, **LD**,
       **LEX**,  **RM**,  **YACC**, etc.).  However, in some traditional uses such an environment variable gives
       options for the program instead of a pathname.  Thus, one has **MORE**, **LESS**, and **GZIP**.  Such us‐
       age  is  considered  mistaken, and to be avoided in new programs.  The authors of _gzip_ should
       consider renaming their option to **GZIP**___**OPT**.

## SEE ALSO
       [**bash**(1)](https://www.chedong.com/phpMan.php/man/bash/1/markdown), [**csh**(1)](https://www.chedong.com/phpMan.php/man/csh/1/markdown), [**env**(1)](https://www.chedong.com/phpMan.php/man/env/1/markdown),  [**login**(1)](https://www.chedong.com/phpMan.php/man/login/1/markdown),  [**printenv**(1)](https://www.chedong.com/phpMan.php/man/printenv/1/markdown),  [**sh**(1)](https://www.chedong.com/phpMan.php/man/sh/1/markdown),  [**tcsh**(1)](https://www.chedong.com/phpMan.php/man/tcsh/1/markdown),  [**execve**(2)](https://www.chedong.com/phpMan.php/man/execve/2/markdown),  [**clearenv**(3)](https://www.chedong.com/phpMan.php/man/clearenv/3/markdown),
       [**exec**(3)](https://www.chedong.com/phpMan.php/man/exec/3/markdown), [**getenv**(3)](https://www.chedong.com/phpMan.php/man/getenv/3/markdown), [**putenv**(3)](https://www.chedong.com/phpMan.php/man/putenv/3/markdown), [**setenv**(3)](https://www.chedong.com/phpMan.php/man/setenv/3/markdown), [**unsetenv**(3)](https://www.chedong.com/phpMan.php/man/unsetenv/3/markdown), [**locale**(7)](https://www.chedong.com/phpMan.php/man/locale/7/markdown), [**ld.so**(8)](https://www.chedong.com/phpMan.php/man/ld.so/8/markdown), **pam**___**[env**(8)](https://www.chedong.com/phpMan.php/man/env/8/markdown)

## COLOPHON
       This  page  is  part  of  release  5.10 of the Linux _man-pages_ project.  A description of the
       project, information about reporting bugs, and the latest version of this page, can be  found
       at <https://www.kernel.org/doc/man-pages/>.



Linux                                        2020-08-13                                   [ENVIRON(7)](https://www.chedong.com/phpMan.php/man/ENVIRON/7/markdown)
