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 .\" SPDX-License-Identifier: GPL-2.0-or-later
7 .\" Modified Sun Jul 25 10:45:30 1993 by Rik Faith (faith@cs.unc.edu)
8 .\" Modified Sun Jul 21 21:25:26 1996 by Andries Brouwer (aeb@cwi.nl)
9 .\" Modified Mon Oct 21 17:47:19 1996 by Eric S. Raymond (esr@thyrsus.com)
10 .\" Modified Wed Aug 27 20:28:58 1997 by Nicolás Lichtmaier (nick@debian.org)
11 .\" Modified Mon Sep 21 00:00:26 1998 by Andries Brouwer (aeb@cwi.nl)
12 .\" Modified Wed Jan 24 06:37:24 2001 by Eric S. Raymond (esr@thyrsus.com)
13 .\" Modified Thu Dec 13 23:53:27 2001 by Martin Schulze <joey@infodrom.org>
15 .TH environ 7 (date) "Linux man-pages (unreleased)"
17 environ \- user environment
20 .BI "extern char **" environ ;
25 points to an array of pointers to strings called the "environment".
26 The last pointer in this array has the value NULL.
27 This array of strings is made available to the process by the
29 call when a new program is started.
30 When a child process is created via
34 of its parent's environment.
36 By convention, the strings in
38 have the form "\fIname\fP\fB=\fP\fIvalue\fP".
39 The name is case-sensitive and may not contain
40 the character "\fB=\fP".
41 The value can be anything that can be represented as a string.
42 The name and the value may not contain an embedded null byte (\[aq]\e0\[aq]),
43 since this is assumed to terminate the string.
45 Environment variables may be placed in the shell's environment by the
54 The initial environment of the shell is populated in various ways,
55 such as definitions from
59 for all users at login time (on systems that employ
61 In addition, various shell initialization scripts, such as the system-wide
63 script and per-user initializations script may include commands
64 that add variables to the shell's environment;
65 see the manual page of your preferred shell for details.
67 Bourne-style shells support the syntax
75 to create an environment variable definition only in the scope
76 of the process that executes
78 Multiple variable definitions, separated by white space, may precede
81 Arguments may also be placed in the
82 environment at the point of an
84 A C program can manipulate its environment using the functions
91 What follows is a list of environment variables typically seen on a
93 This list is incomplete and includes only common variables seen
94 by average users in their day-to-day routine.
95 Environment variables specific to a particular program or library function
96 are documented in the ENVIRONMENT section of the appropriate manual page.
99 The name of the logged-in user (used by some BSD-derived programs).
100 Set at login time, see section NOTES below.
103 The name of the logged-in user (used by some System-V derived programs).
104 Set at login time, see section NOTES below.
107 A user's login directory.
108 Set at login time, see section NOTES below.
111 The name of a locale to use for locale categories when not overridden
114 or more specific environment variables such as
124 for further details of the
126 environment variables).
129 The sequence of directory prefixes that
132 programs employ when searching for an executable file that is specified
133 as a simple filename (i.a., a pathname that contains no slashes).
134 The prefixes are separated by colons (\fB:\fP).
135 The list of prefixes is searched from beginning to end,
136 by checking the pathname formed by concatenating
137 a prefix, a slash, and the filename,
138 until a file with execute permission is found.
140 As a legacy feature, a zero-length prefix
141 (specified as two adjacent colons, or an initial or terminating colon)
142 is interpreted to mean the current working directory.
143 However, use of this feature is deprecated,
144 and POSIX notes that a conforming application shall use
145 an explicit pathname (e.g.,
147 to specify the current working directory.
153 used by some shells to find the target
154 of a change directory command,
158 to find manual pages, and so on.
161 Absolute path to the current working directory;
162 required to be partially canonical (no
169 The absolute pathname of the user's login shell.
170 Set at login time, see section NOTES below.
173 The terminal type for which output is to be prepared.
176 The user's preferred utility to display text files.
177 Any string acceptable as a command-string operand to the
179 command shall be valid.
182 is null or is not set,
183 then applications that launch a pager will default to a program such as
189 The user's preferred utility to edit text files.
190 Any string acceptable as a command_string operand to the
192 command shall be valid.
195 .\" The user's preferred utility to browse URLs. Sequence of colon-separated
196 .\" browser commands. See http://www.catb.org/\[ti]esr/BROWSER/ .
198 Note that the behavior of many programs and library routines is
199 influenced by the presence or value of certain environment variables.
200 Examples include the following:
203 .BR LANG ", " LANGUAGE ", " NLSPATH ", " LOCPATH ,
204 .BR LC_ALL ", " LC_MESSAGES ,
205 and so on influence locale handling; see
212 influences the path prefix of names created by
214 and other routines, and the temporary directory used by
218 .BR LD_LIBRARY_PATH ", " LD_PRELOAD ,
221 variables influence the behavior of the dynamic loader/linker.
226 makes certain programs and library routines follow
227 the prescriptions of POSIX.
237 gives the name of a file containing aliases
239 .BR gethostbyname (3).
242 give timezone information used by
244 and through that by functions like
253 gives information on how to address a given terminal
254 (or gives the name of a file containing such information).
256 .BR COLUMNS " and " LINES
257 tell applications about the window size, possibly overriding the actual size.
259 .BR PRINTER " or " LPDEST
260 may specify the desired printer to use.
264 Historically and by standard,
266 must be declared in the user program.
267 However, as a (nonstandard) programmer convenience,
269 is declared in the header file
273 feature test macro is defined (see
274 .BR feature_test_macros (7)).
278 .B PR_SET_MM_ENV_START
281 operations can be used to control the location of the process's environment.
289 variables are set when the user is changed via a
290 session management interface, typically by a program such as
292 from a user database (such as
294 (Switching to the root user using
296 may result in a mixed environment where
300 are retained from old user; see the
304 Clearly there is a security risk here.
305 Many a system command has been
306 tricked into mischief by a user who specified unusual values for
307 .BR IFS " or " LD_LIBRARY_PATH .
309 There is also the risk of name space pollution.
314 allow overriding of default utility names from the
315 environment with similarly named variables in all caps.
318 to select the desired C compiler (and similarly
328 However, in some traditional uses such an environment variable
329 gives options for the program instead of a pathname.
334 Such usage is considered mistaken, and to be avoided in new