1environ(7)             Miscellaneous Information 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 array of strings is made available to the process by the execve(2)
15       call when a new program is started.  When a child  process  is  created
16       via fork(2), it inherits a copy of its parent's environment.
17
18       By  convention, the strings in environ have the form "name=value".  The
19       name is case-sensitive and may not  contain  the  character  "=".   The
20       value  can  be  anything that can be represented as a string.  The name
21       and the value may not contain an embedded null byte ('\0'), since  this
22       is assumed to terminate the string.
23
24       Environment  variables  may be placed in the shell's environment by the
25       export command in sh(1), or by the setenv command if you use csh(1).
26
27       The initial environment of the shell is populated in various ways, such
28       as  definitions  from /etc/environment that are processed by pam_env(8)
29       for all users at login time (on systems that employ pam(8)).  In  addi‐
30       tion,  various  shell  initialization  scripts, such as the system-wide
31       /etc/profile script and per-user  initializations  script  may  include
32       commands  that add variables to the shell's environment; see the manual
33       page of your preferred shell for details.
34
35       Bourne-style shells support the syntax
36
37           NAME=value command
38
39       to create an environment variable definition only in the scope  of  the
40       process  that  executes  command.  Multiple variable definitions, sepa‐
41       rated by white space, may precede command.
42
43       Arguments may also be placed in the environment  at  the  point  of  an
44       exec(3).   A  C  program can manipulate its environment using the func‐
45       tions getenv(3), putenv(3), setenv(3), and unsetenv(3).
46
47       What follows is a list of environment variables  typically  seen  on  a
48       system.   This  list  is  incomplete and includes only common variables
49       seen by average users in their day-to-day routine.   Environment  vari‐
50       ables  specific  to  a particular program or library function are docu‐
51       mented in the ENVIRONMENT section of the appropriate manual page.
52
53       USER   The name of the logged-in user (used by  some  BSD-derived  pro‐
54              grams).  Set at login time, see section NOTES below.
55
56       LOGNAME
57              The  name  of  the logged-in user (used by some System-V derived
58              programs).  Set at login time, see section NOTES below.
59
60       HOME   A user's login directory.  Set at login time, see section  NOTES
61              below.
62
63       LANG   The name of a locale to use for locale categories when not over‐
64              ridden by LC_ALL or more specific environment variables such  as
65              LC_COLLATE,  LC_CTYPE, LC_MESSAGES, LC_MONETARY, LC_NUMERIC, and
66              LC_TIME (see locale(7) for further details of the LC_*  environ‐
67              ment variables).
68
69       PATH   The  sequence  of  directory  prefixes that sh(1) and many other
70              programs employ when searching for an executable  file  that  is
71              specified  as  a simple filename (i.a., a pathname that contains
72              no slashes).  The prefixes are separated  by  colons  (:).   The
73              list  of prefixes is searched from beginning to end, by checking
74              the pathname formed by concatenating a prefix, a slash, and  the
75              filename, until a file with execute permission is found.
76
77              As  a legacy feature, a zero-length prefix (specified as two ad‐
78              jacent colons, or an initial or  terminating  colon)  is  inter‐
79              preted  to  mean the current working directory.  However, use of
80              this feature is deprecated, and POSIX notes  that  a  conforming
81              application shall use an explicit pathname (e.g., .)  to specify
82              the current working directory.
83
84              Analogously to PATH, one has CDPATH used by some shells to  find
85              the target of a change directory command, MANPATH used by man(1)
86              to find manual pages, and so on.
87
88       PWD    Absolute path to the current working directory; required  to  be
89              partially canonical (no . or .. components).
90
91       SHELL  The  absolute  pathname of the user's login shell.  Set at login
92              time, see section NOTES below.
93
94       TERM   The terminal type for which output is to be prepared.
95
96       PAGER  The user's preferred utility to display text files.  Any  string
97              acceptable  as  a  command-string  operand  to the sh -c command
98              shall be valid.  If PAGER is null or is not set,  then  applica‐
99              tions  that  launch  a  pager  will default to a program such as
100              less(1) or more(1).
101
102       EDITOR/VISUAL
103              The user's preferred utility to edit text files.  Any string ac‐
104              ceptable  as a command_string operand to the sh -c command shall
105              be valid.
106
107       Note that the behavior of many programs and library routines is  influ‐
108       enced by the presence or value of certain environment variables.  Exam‐
109       ples include the following:
110
111       •  The variables LANG, LANGUAGE, NLSPATH, LOCPATH, LC_ALL, LC_MESSAGES,
112          and so on influence locale handling; see catopen(3), gettext(3), and
113          locale(7).
114
115TMPDIR influences the path prefix of names created by tempnam(3) and
116          other  routines,  and  the  temporary  directory used by sort(1) and
117          other programs.
118
119LD_LIBRARY_PATH, LD_PRELOAD, and other LD_* variables influence  the
120          behavior of the dynamic loader/linker.  See also ld.so(8).
121
122POSIXLY_CORRECT  makes  certain programs and library routines follow
123          the prescriptions of POSIX.
124
125       •  The behavior of malloc(3) is influenced by MALLOC_* variables.
126
127       •  The variable HOSTALIASES gives the name of a file containing aliases
128          to be used with gethostbyname(3).
129
130TZ  and TZDIR give timezone information used by tzset(3) and through
131          that by functions  like  ctime(3),  localtime(3),  mktime(3),  strf‐
132          time(3).  See also tzselect(8).
133
134TERMCAP  gives  information  on  how to address a given terminal (or
135          gives the name of a file containing such information).
136
137COLUMNS and LINES tell applications about the window size,  possibly
138          overriding the actual size.
139
140PRINTER  or  LPDEST  may  specify  the  desired printer to use.  See
141          lpr(1).
142

NOTES

144       Historically and by standard, environ must be declared in the user pro‐
145       gram.   However,  as a (nonstandard) programmer convenience, environ is
146       declared in the header file <unistd.h> if the _GNU_SOURCE feature  test
147       macro is defined (see feature_test_macros(7)).
148
149       The  prctl(2)  PR_SET_MM_ENV_START and PR_SET_MM_ENV_END operations can
150       be used to control the location of the process's environment.
151
152       The HOME, LOGNAME, SHELL, and USER variables are set when the  user  is
153       changed via a session management interface, typically by a program such
154       as login(1) from a user database (such as  passwd(5)).   (Switching  to
155       the  root user using su(1) may result in a mixed environment where LOG‐
156       NAME and USER are retained from old user; see the su(1) manual page.)
157

BUGS

159       Clearly there is a security risk here.  Many a system command has  been
160       tricked into mischief by a user who specified unusual values for IFS or
161       LD_LIBRARY_PATH.
162
163       There is also the risk of name space pollution.  Programs like make and
164       autoconf allow overriding of default utility names from the environment
165       with similarly named variables in all caps.  Thus one uses CC to select
166       the  desired  C  compiler (and similarly MAKE, AR, AS, FC, LD, LEX, RM,
167       YACC, etc.).  However, in some traditional  uses  such  an  environment
168       variable  gives  options  for the program instead of a pathname.  Thus,
169       one has MORE and LESS.  Such usage is considered mistaken,  and  to  be
170       avoided in new programs.
171

SEE ALSO

173       bash(1),  csh(1), env(1), login(1), printenv(1), sh(1), su(1), tcsh(1),
174       execve(2), clearenv(3), exec(3), getenv(3), putenv(3),  setenv(3),  un‐
175       setenv(3), locale(7), ld.so(8), pam_env(8)
176
177
178
179Linux man-pages 6.04              2023-02-05                        environ(7)
Impressum