]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man7/environ.7
mdoc.7: Add a cross-reference to groff_mdoc(7)
[thirdparty/man-pages.git] / man7 / environ.7
CommitLineData
fea681da
MK
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.
4.\"
1dd72f9c 5.\" %%%LICENSE_START(GPLv2+_DOC_FULL)
fea681da
MK
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.
10.\"
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.
15.\"
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.
20.\"
21.\" You should have received a copy of the GNU General Public
c715f741
MK
22.\" License along with this manual; if not, see
23.\" <http://www.gnu.org/licenses/>.
6a8d8745 24.\" %%%LICENSE_END
c13182ef 25.\"
fea681da
MK
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)
e00c3a07 29.\" Modified Wed Aug 27 20:28:58 1997 by Nicolás Lichtmaier (nick@debian.org)
fea681da
MK
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>
33.\"
b8efb414 34.TH ENVIRON 7 2016-10-08 "Linux" "Linux Programmer's Manual"
fea681da
MK
35.SH NAME
36environ \- user environment
37.SH SYNOPSIS
fea681da 38.nf
a45ebabf 39.BI "extern char **" environ ;
fea681da
MK
40.br
41.fi
fea681da
MK
42.SH DESCRIPTION
43The variable
44.I environ
86d9ea37 45points to an array of pointers to strings called the "environment".
d6584e22 46The last pointer in this array has the value NULL.
fea681da
MK
47(This variable must be declared in the user program,
48but is declared in the header file
bd12ab88 49.I <unistd.h>
1740dfa1 50if the
fea681da 51.B _GNU_SOURCE
1740dfa1 52feature test macro is defined.)
fea681da
MK
53This array of strings is made available to the process by the
54.BR exec (3)
c13182ef 55call that started the process.
9c67b250
MK
56When a child process is created via
57.BR fork (2),
58it inherits a
59.I copy
60of its parent's environment.
86d9ea37
MK
61
62By convention the strings in
63.I environ
2d986c92 64have the form "\fIname\fP\fB=\fP\fIvalue\fP".
c13182ef 65Common examples are:
fea681da
MK
66.TP
67.B USER
68The name of the logged-in user (used by some BSD-derived programs).
69.TP
70.B LOGNAME
71The name of the logged-in user (used by some System-V derived programs).
72.TP
73.B HOME
74A user's login directory, set by
75.BR login (1)
76from the password file
77.BR passwd (5).
78.TP
79.B LANG
80The name of a locale to use for locale categories when not overridden
c6fa0841
MK
81by
82.B LC_ALL
342a96c6 83or more specific environment variables such as
c6fa0841
MK
84.BR LC_COLLATE ,
85.BR LC_CTYPE ,
86.BR LC_MESSAGES ,
87.BR LC_MONETARY ,
88.BR LC_NUMERIC ,
d4d91728
MK
89and
90.BR LC_TIME
91(see
92.BR locale (7)
93for further details of the
94.BR LC_*
95environment variables).
fea681da
MK
96.TP
97.B PATH
60a90ecd
MK
98The sequence of directory prefixes that
99.BR sh (1)
100and many other
2d7195b8 101programs apply in searching for a file known by an incomplete pathname.
f81fb444 102The prefixes are separated by \(aq\fB:\fP\(aq.
c6fa0841
MK
103(Similarly one has
104.B CDPATH
105used by some shells to find the target
106of a change directory command,
107.B MANPATH
108used by
60a90ecd 109.BR man (1)
e5138434 110to find manual pages, and so on)
fea681da
MK
111.TP
112.B PWD
c13182ef
MK
113The current working directory.
114Set by some shells.
fea681da
MK
115.TP
116.B SHELL
2c5f1089 117The pathname of the user's login shell.
fea681da
MK
118.TP
119.B TERM
120The terminal type for which output is to be prepared.
121.TP
122.B PAGER
123The user's preferred utility to display text files.
124.TP
125.BR EDITOR / VISUAL
126The user's preferred utility to edit text files.
7739f1d4
MK
127.\" .TP
128.\" .B BROWSER
129.\" The user's preferred utility to browse URLs. Sequence of colon-separated
130.\" browser commands. See http://www.catb.org/~esr/BROWSER/ .
fea681da 131.PP
170eb741 132Names may be placed in the shell's environment by the
c6fa0841 133.I export
789fdd93 134command in
fea681da 135.BR sh (1),
c6fa0841
MK
136or by the
137.I setenv
138command if you use
fea681da 139.BR csh (1).
789fdd93 140
94d3ac09
MK
141The initial environment of the shell is populated in various ways,
142such as definitions from
143.IR /etc/environment
144that are processed by
145.BR pam_env (8)
146for all users at login time (on systems that employ
147.BR pam (8)).
148In addition, various shell initialization scripts, such as the system-wide
149.IR /etc/profile
150script and per-user initializations script may include commands
151that add variables to the shell's environment;
152see the manual page of your preferred shell for details.
153
170eb741
MK
154Bourne-style shells support the syntax
155
156 NAME=value command
157
158to create an environment variable definition only in the scope
159of the process that executes
160.IR command .
161Multiple variable definitions, separated by white space, may precede
162.IR command .
163
fea681da
MK
164Arguments may also be placed in the
165environment at the point of an
166.BR exec (3).
167A C program can manipulate its environment using the functions
168.BR getenv (3),
169.BR putenv (3),
170.BR setenv (3),
171and
172.BR unsetenv (3).
173
d9bfdb9c 174Note that the behavior of many programs and library routines is
fea681da
MK
175influenced by the presence or value of certain environment variables.
176A random collection:
177.LP
178The variables
c13182ef 179.BR LANG ", " LANGUAGE ", " NLSPATH ", " LOCPATH ", "
35478399 180.BR LC_ALL ", " LC_MESSAGES ", "
3a6d5615
MK
181and so on influence locale handling; see
182.BR catopen (3),
183.BR gettext (3),
184and
185.BR locale (7).
fea681da
MK
186.LP
187.B TMPDIR
188influences the path prefix of names created by
3f7aa9fc 189.BR tmpnam (3)
f78ed33a 190and other routines, and the temporary directory used by
60a90ecd 191.BR sort (1)
f78ed33a 192and other programs.
fea681da
MK
193.LP
194.BR LD_LIBRARY_PATH ", " LD_PRELOAD
195and other LD_* variables influence
d9bfdb9c 196the behavior of the dynamic loader/linker.
fea681da
MK
197.LP
198.B POSIXLY_CORRECT
199makes certain programs and library routines follow
200the prescriptions of POSIX.
201.LP
d9bfdb9c 202The behavior of
60a90ecd 203.BR malloc (3)
c7496b03
MK
204is influenced by
205.B MALLOC_*
206variables.
fea681da
MK
207.LP
208The variable
209.B HOSTALIASES
210gives the name of a file containing aliases
60a90ecd
MK
211to be used with
212.BR gethostbyname (3).
fea681da
MK
213.LP
214.BR TZ " and " TZDIR
5b0dc1ba 215give timezone information used by
fea681da
MK
216.BR tzset (3)
217and through that by functions like
2a85592a
MK
218.BR ctime (3),
219.BR localtime (3),
220.BR mktime (3),
221.BR strftime (3).
fea681da 222See also
2a85592a 223.BR tzselect (8).
fea681da
MK
224.LP
225.B TERMCAP
226gives information on how to address a given terminal
227(or gives the name of a file containing such information).
228.LP
229.BR COLUMNS " and " LINES
230tell applications about the window size, possibly overriding the actual size.
231.LP
232.BR PRINTER " or " LPDEST
c13182ef
MK
233may specify the desired printer to use.
234See
fea681da 235.BR lpr (1).
fea681da 236.SH BUGS
c13182ef
MK
237Clearly there is a security risk here.
238Many a system command has been
fea681da
MK
239tricked into mischief by a user who specified unusual values for
240.BR IFS " or " LD_LIBRARY_PATH .
241
242There is also the risk of name space pollution.
243Programs like
244.I make
245and
246.I autoconf
247allow overriding of default utility names from the
248environment with similarly named variables in all caps.
249Thus one uses
250.B CC
251to select the desired C compiler (and similarly
252.BR MAKE ,
253.BR AR ,
254.BR AS ,
255.BR FC ,
256.BR LD ,
257.BR LEX ,
258.BR RM ,
259.BR YACC ,
260etc.).
261However, in some traditional uses such an environment variable
262gives options for the program instead of a pathname.
263Thus, one has
264.BR MORE ,
265.BR LESS ,
266and
267.BR GZIP .
268Such usage is considered mistaken, and to be avoided in new
c13182ef
MK
269programs.
270The authors of
fea681da
MK
271.I gzip
272should consider renaming their option to
273.BR GZIP_OPT .
47297adb 274.SH SEE ALSO
fea681da
MK
275.BR bash (1),
276.BR csh (1),
109aa73d 277.BR env (1),
fea681da 278.BR login (1),
3f205b20 279.BR printenv (1),
fea681da
MK
280.BR sh (1),
281.BR tcsh (1),
282.BR execve (2),
283.BR clearenv (3),
284.BR exec (3),
285.BR getenv (3),
2705ab40 286.BR pam_env (3),
fea681da
MK
287.BR putenv (3),
288.BR setenv (3),
289.BR unsetenv (3),
3f205b20
MK
290.BR locale (7),
291.BR ld.so (8)