1 .\" Copyright (c) 1993 Michael Haardt (michael@moria.de),
2 .\" Fri Apr 2 11:32:09 MET DST 1993
3 .\" and Andries Brouwer (aeb@cwi.nl), Fri Feb 14 21:47:50 1997.
5 .\" %%%LICENSE_START(GPLv2+_DOC_FULL)
6 .\" This is free documentation; you can redistribute it and/or
7 .\" modify it under the terms of the GNU General Public License as
8 .\" published by the Free Software Foundation; either version 2 of
9 .\" the License, or (at your option) any later version.
11 .\" The GNU General Public License's references to "object code"
12 .\" and "executables" are to be interpreted as the output of any
13 .\" document formatting or typesetting system, including
14 .\" intermediate and printed output.
16 .\" This manual is distributed in the hope that it will be useful,
17 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
18 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 .\" GNU General Public License for more details.
21 .\" You should have received a copy of the GNU General Public
22 .\" License along with this manual; if not, see
23 .\" <http://www.gnu.org/licenses/>.
26 .\" Modified Sun Jul 25 10:45:30 1993 by Rik Faith (faith@cs.unc.edu)
27 .\" Modified Sun Jul 21 21:25:26 1996 by Andries Brouwer (aeb@cwi.nl)
28 .\" Modified Mon Oct 21 17:47:19 1996 by Eric S. Raymond (esr@thyrsus.com)
29 .\" Modified Wed Aug 27 20:28:58 1997 by Nicolás Lichtmaier (nick@debian.org)
30 .\" Modified Mon Sep 21 00:00:26 1998 by Andries Brouwer (aeb@cwi.nl)
31 .\" Modified Wed Jan 24 06:37:24 2001 by Eric S. Raymond (esr@thyrsus.com)
32 .\" Modified Thu Dec 13 23:53:27 2001 by Martin Schulze <joey@infodrom.org>
34 .TH ENVIRON 7 2021-03-22 "Linux" "Linux Programmer's Manual"
36 environ \- user environment
39 .BI "extern char **" environ ;
44 points to an array of pointers to strings called the "environment".
45 The last pointer in this array has the value NULL.
46 This array of strings is made available to the process by the
48 call when a new program is started.
49 When a child process is created via
53 of its parent's environment.
55 By convention, the strings in
57 have the form "\fIname\fP\fB=\fP\fIvalue\fP".
58 The name is case-sensitive and may not contain
59 the character "\fB=\fP".
60 The value can be anything that can be represented as a string.
61 The name and the value may not contain an embedded null byte (\(aq\e0\(aq),
62 since this is assumed to terminate the string.
64 Environment variables may be placed in the shell's environment by the
73 The initial environment of the shell is populated in various ways,
74 such as definitions from
78 for all users at login time (on systems that employ
80 In addition, various shell initialization scripts, such as the system-wide
82 script and per-user initializations script may include commands
83 that add variables to the shell's environment;
84 see the manual page of your preferred shell for details.
86 Bourne-style shells support the syntax
90 to create an environment variable definition only in the scope
91 of the process that executes
93 Multiple variable definitions, separated by white space, may precede
96 Arguments may also be placed in the
97 environment at the point of an
99 A C program can manipulate its environment using the functions
106 What follows is a list of environment variables typically seen on a
108 This list is incomplete and includes only common variables seen
109 by average users in their day-to-day routine.
110 Environment variables specific to a particular program or library function
111 are documented in the ENVIRONMENT section of the appropriate manual page.
114 The name of the logged-in user (used by some BSD-derived programs).
115 Set at login time, see section NOTES below.
118 The name of the logged-in user (used by some System-V derived programs).
119 Set at login time, see section NOTES below.
122 A user's login directory.
123 Set at login time, see section NOTES below.
126 The name of a locale to use for locale categories when not overridden
129 or more specific environment variables such as
139 for further details of the
141 environment variables).
144 The sequence of directory prefixes that
147 programs employ when searching for an executable file that is specified
148 as a simple filename (i.a., a pathname that contains no slashes).
149 The prefixes are separated by colons (\fB:\fP).
150 The list of prefixes is searched from beginning to end,
151 by checking the pathname formed by concatenating
152 a prefix, a slash, and the filename,
153 until a file with execute permission is found.
155 As a legacy feature, a zero-length prefix
156 (specified as two adjacent colons, or an initial or terminating colon)
157 is interpreted to mean the current working directory.
158 However, use of this feature is deprecated,
159 and POSIX notes that a conforming application shall use
160 an explicit pathname (e.g.,
162 to specify the current working directory.
168 used by some shells to find the target
169 of a change directory command,
173 to find manual pages, and so on.
176 The current working directory.
180 The absolute pathname of the user's login shell.
181 Set at login time, see section NOTES below.
184 The terminal type for which output is to be prepared.
187 The user's preferred utility to display text files.
188 Any string acceptable as a command-string operand to the
190 command shall be valid.
193 is null or is not set,
194 then applications that launch a pager will default to a program such as
200 The user's preferred utility to edit text files.
201 Any string acceptable as a command_string operand to the
203 command shall be valid.
206 .\" The user's preferred utility to browse URLs. Sequence of colon-separated
207 .\" browser commands. See http://www.catb.org/\(tiesr/BROWSER/ .
209 Note that the behavior of many programs and library routines is
210 influenced by the presence or value of certain environment variables.
211 Examples include the following:
214 .BR LANG ", " LANGUAGE ", " NLSPATH ", " LOCPATH ,
215 .BR LC_ALL ", " LC_MESSAGES ,
216 and so on influence locale handling; see
223 influences the path prefix of names created by
225 and other routines, and the temporary directory used by
229 .BR LD_LIBRARY_PATH ", " LD_PRELOAD ,
232 variables influence the behavior of the dynamic loader/linker.
237 makes certain programs and library routines follow
238 the prescriptions of POSIX.
248 gives the name of a file containing aliases
250 .BR gethostbyname (3).
253 give timezone information used by
255 and through that by functions like
264 gives information on how to address a given terminal
265 (or gives the name of a file containing such information).
267 .BR COLUMNS " and " LINES
268 tell applications about the window size, possibly overriding the actual size.
270 .BR PRINTER " or " LPDEST
271 may specify the desired printer to use.
275 Historically and by standard,
277 must be declared in the user program.
278 However, as a (nonstandard) programmer convenience,
280 is declared in the header file
284 feature test macro is defined (see
285 .BR feature_test_macros (7)).
289 .B PR_SET_MM_ENV_START
292 operations can be used to control the location of the process's environment.
300 variables are set when the user is changed via a
301 session management interface, typically by a program such as
303 from a user database (such as
305 (Switching to the root user using
307 may result in a mixed environment where
311 are retained from old user; see the
315 Clearly there is a security risk here.
316 Many a system command has been
317 tricked into mischief by a user who specified unusual values for
318 .BR IFS " or " LD_LIBRARY_PATH .
320 There is also the risk of name space pollution.
325 allow overriding of default utility names from the
326 environment with similarly named variables in all caps.
329 to select the desired C compiler (and similarly
339 However, in some traditional uses such an environment variable
340 gives options for the program instead of a pathname.
345 Such usage is considered mistaken, and to be avoided in new