1ENVIRON(7)                 Linux Programmer's Manual                ENVIRON(7)
2
3
4

NAME

6       environ - user environment
7

SYNOPSIS

9       extern char **environ;
10

DESCRIPTION

12       The  variable  environ points to an array of pointers to strings called
13       the "environment".  The last pointer in this array has the value  NULL.
14       (This variable must be declared in the user program, but is declared in
15       the header file <unistd.h> if the _GNU_SOURCE  feature  test  macro  is
16       defined.)   This  array  of strings is made available to the process by
17       the exec(3) call that started the process.  When  a  child  process  is
18       created via fork(2), it inherits a copy of its parent's environment.
19
20       By  convention the strings in environ have the form "name=value".  Com‐
21       mon examples are:
22
23       USER   The name of the logged-in user (used by  some  BSD-derived  pro‐
24              grams).
25
26       LOGNAME
27              The  name  of  the logged-in user (used by some System-V derived
28              programs).
29
30       HOME   A user's login directory, set by login(1) from the password file
31              passwd(5).
32
33       LANG   The name of a locale to use for locale categories when not over‐
34              ridden by LC_ALL or more specific environment variables such  as
35              LC_COLLATE,  LC_CTYPE, LC_MESSAGES, LC_MONETARY, LC_NUMERIC, and
36              LC_TIME (see locale(7) for further details of the LC_*  environ‐
37              ment variables).
38
39       PATH   The  sequence  of  directory  prefixes that sh(1) and many other
40              programs apply in searching for a file known  by  an  incomplete
41              pathname.   The  prefixes  are separated by ':'.  (Similarly one
42              has CDPATH used by some shells to find the target  of  a  change
43              directory  command, MANPATH used by man(1) to find manual pages,
44              and so on)
45
46       PWD    The current working directory.  Set by some shells.
47
48       SHELL  The pathname of the user's login shell.
49
50       TERM   The terminal type for which output is to be prepared.
51
52       PAGER  The user's preferred utility to display text files.
53
54       EDITOR/VISUAL
55              The user's preferred utility to edit text files.
56
57       Names may be placed in the shell's environment by the export command in
58       sh(1), or by the setenv command if you use csh(1).
59
60       The initial environment of the shell is populated in various ways, such
61       as definitions from /etc/environment that are processed  by  pam_env(8)
62       for  all users at login time (on systems that employ pam(8)).  In addi‐
63       tion, various shell initialization scripts,  such  as  the  system-wide
64       /etc/profile  script  and  per-user  initializations script may include
65       commands that add variables to the shell's environment; see the  manual
66       page of your preferred shell for details.
67
68       Bourne-style shells support the syntax
69
70           NAME=value command
71
72       to  create  an environment variable definition only in the scope of the
73       process that executes command.  Multiple  variable  definitions,  sepa‐
74       rated by white space, may precede command.
75
76       Arguments  may  also  be  placed  in the environment at the point of an
77       exec(3).  A C program can manipulate its environment  using  the  func‐
78       tions getenv(3), putenv(3), setenv(3), and unsetenv(3).
79
80       Note  that the behavior of many programs and library routines is influ‐
81       enced by the presence or value of certain environment variables.  Exam‐
82       ples include the following:
83
84       *  The variables LANG, LANGUAGE, NLSPATH, LOCPATH, LC_ALL, LC_MESSAGES,
85          and so on influence locale handling; see catopen(3), gettext(3), and
86          locale(7).
87
88       *  TMPDIR influences the path prefix of names created by tempnam(3) and
89          other routines, and the temporary  directory  used  by  sort(1)  and
90          other programs.
91
92       *  LD_LIBRARY_PATH,  LD_PRELOAD, and other LD_* variables influence the
93          behavior of the dynamic loader/linker.
94
95       *  POSIXLY_CORRECT makes certain programs and library  routines  follow
96          the prescriptions of POSIX.
97
98       *  The behavior of malloc(3) is influenced by MALLOC_* variables.
99
100       *  The variable HOSTALIASES gives the name of a file containing aliases
101          to be used with gethostbyname(3).
102
103       *  TZ and TZDIR give timezone information used by tzset(3) and  through
104          that  by  functions  like  ctime(3),  localtime(3), mktime(3), strf‐
105          time(3).  See also tzselect(8).
106
107       *  TERMCAP gives information on how to address  a  given  terminal  (or
108          gives the name of a file containing such information).
109
110       *  COLUMNS  and LINES tell applications about the window size, possibly
111          overriding the actual size.
112
113       *  PRINTER or LPDEST may specify  the  desired  printer  to  use.   See
114          lpr(1).
115

NOTES

117       The  prctl(2)  PR_SET_MM_ENV_START and PR_SET_MM_ENV_END operations can
118       be used to control the location of the process's environment.
119

BUGS

121       Clearly there is a security risk here.  Many a system command has  been
122       tricked into mischief by a user who specified unusual values for IFS or
123       LD_LIBRARY_PATH.
124
125       There is also the risk of name space pollution.  Programs like make and
126       autoconf allow overriding of default utility names from the environment
127       with similarly named variables in all caps.  Thus one uses CC to select
128       the  desired  C  compiler (and similarly MAKE, AR, AS, FC, LD, LEX, RM,
129       YACC, etc.).  However, in some traditional  uses  such  an  environment
130       variable  gives  options  for the program instead of a pathname.  Thus,
131       one has MORE, LESS, and GZIP.  Such usage is considered  mistaken,  and
132       to  be  avoided  in  new programs.  The authors of gzip should consider
133       renaming their option to GZIP_OPT.
134

SEE ALSO

136       bash(1),  csh(1),  env(1),  login(1),  printenv(1),   sh(1),   tcsh(1),
137       execve(2),   clearenv(3),  exec(3),  getenv(3),  putenv(3),  setenv(3),
138       unsetenv(3), locale(7), ld.so(8), pam_env(8)
139

COLOPHON

141       This page is part of release 5.04 of the Linux  man-pages  project.   A
142       description  of  the project, information about reporting bugs, and the
143       latest    version    of    this    page,    can     be     found     at
144       https://www.kernel.org/doc/man-pages/.
145
146
147
148Linux                             2017-09-15                        ENVIRON(7)
Impressum