2004-11-03 13:51:07 +00:00
|
|
|
|
.\" Copyright (c) 1993 Michael Haardt (michael@moria.de),
|
|
|
|
|
.\" Fri Apr 2 11:32:09 MET DST 1993
|
|
|
|
|
.\" and Andries Brouwer (aeb@cwi.nl), Fri Feb 14 21:47:50 1997.
|
|
|
|
|
.\"
|
|
|
|
|
.\" This is free documentation; you can redistribute it and/or
|
|
|
|
|
.\" modify it under the terms of the GNU General Public License as
|
|
|
|
|
.\" published by the Free Software Foundation; either version 2 of
|
|
|
|
|
.\" the License, or (at your option) any later version.
|
|
|
|
|
.\"
|
|
|
|
|
.\" The GNU General Public License's references to "object code"
|
|
|
|
|
.\" and "executables" are to be interpreted as the output of any
|
|
|
|
|
.\" document formatting or typesetting system, including
|
|
|
|
|
.\" intermediate and printed output.
|
|
|
|
|
.\"
|
|
|
|
|
.\" This manual is distributed in the hope that it will be useful,
|
|
|
|
|
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
.\" GNU General Public License for more details.
|
|
|
|
|
.\"
|
|
|
|
|
.\" You should have received a copy of the GNU General Public
|
|
|
|
|
.\" License along with this manual; if not, write to the Free
|
|
|
|
|
.\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
|
|
|
|
|
.\" USA.
|
2007-04-12 22:42:49 +00:00
|
|
|
|
.\"
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.\" Modified Sun Jul 25 10:45:30 1993 by Rik Faith (faith@cs.unc.edu)
|
|
|
|
|
.\" Modified Sun Jul 21 21:25:26 1996 by Andries Brouwer (aeb@cwi.nl)
|
|
|
|
|
.\" Modified Mon Oct 21 17:47:19 1996 by Eric S. Raymond (esr@thyrsus.com)
|
|
|
|
|
.\" Modified Wed Aug 27 20:28:58 1997 by Nicol<6F>s Lichtmaier (nick@debian.org)
|
|
|
|
|
.\" Modified Mon Sep 21 00:00:26 1998 by Andries Brouwer (aeb@cwi.nl)
|
|
|
|
|
.\" Modified Wed Jan 24 06:37:24 2001 by Eric S. Raymond (esr@thyrsus.com)
|
|
|
|
|
.\" Modified Thu Dec 13 23:53:27 2001 by Martin Schulze <joey@infodrom.org>
|
|
|
|
|
.\"
|
2006-04-21 00:45:46 +00:00
|
|
|
|
.TH ENVIRON 7 2001-12-14 "Linux" "Linux Programmer's Manual"
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.SH NAME
|
|
|
|
|
environ \- user environment
|
|
|
|
|
.SH SYNOPSIS
|
|
|
|
|
.ad l
|
|
|
|
|
.nf
|
|
|
|
|
.B extern char **environ;
|
|
|
|
|
.br
|
|
|
|
|
.fi
|
|
|
|
|
.ad b
|
|
|
|
|
.SH DESCRIPTION
|
|
|
|
|
The variable
|
|
|
|
|
.I environ
|
|
|
|
|
points to an array of strings called the `environment'.
|
|
|
|
|
(This variable must be declared in the user program,
|
|
|
|
|
but is declared in the header file
|
2005-11-03 12:47:27 +00:00
|
|
|
|
.I <unistd.h>
|
2004-11-03 13:51:07 +00:00
|
|
|
|
in case the header files came from libc4 or libc5, and
|
|
|
|
|
in case they came from glibc and
|
|
|
|
|
.B _GNU_SOURCE
|
|
|
|
|
was defined.)
|
|
|
|
|
This array of strings is made available to the process by the
|
|
|
|
|
.BR exec (3)
|
2007-04-12 22:42:49 +00:00
|
|
|
|
call that started the process.
|
|
|
|
|
By convention these strings
|
|
|
|
|
have the form `\fIname\fP\fB=\fP\fIvalue\fP'.
|
|
|
|
|
Common examples are:
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.TP
|
|
|
|
|
.B USER
|
|
|
|
|
The name of the logged-in user (used by some BSD-derived programs).
|
|
|
|
|
.TP
|
|
|
|
|
.B LOGNAME
|
|
|
|
|
The name of the logged-in user (used by some System-V derived programs).
|
|
|
|
|
.TP
|
|
|
|
|
.B HOME
|
|
|
|
|
A user's login directory, set by
|
|
|
|
|
.BR login (1)
|
|
|
|
|
from the password file
|
|
|
|
|
.BR passwd (5).
|
|
|
|
|
.TP
|
|
|
|
|
.B LANG
|
|
|
|
|
The name of a locale to use for locale categories when not overridden
|
|
|
|
|
by \fBLC_ALL\fP or more specific environment variables like
|
|
|
|
|
\fBLC_COLLATE\fP, \fBLC_CTYPE\fP, \fBLC_MESSAGES\fP, \fBLC_MONETARY\fP,
|
|
|
|
|
\fBLC_NUMERIC\fP, \fBLC_TIME\fP, cf.
|
|
|
|
|
.BR locale (5).
|
|
|
|
|
.TP
|
|
|
|
|
.B PATH
|
2007-05-12 09:06:04 +00:00
|
|
|
|
The sequence of directory prefixes that
|
|
|
|
|
.BR sh (1)
|
|
|
|
|
and many other
|
2006-02-12 22:19:08 +00:00
|
|
|
|
programs apply in searching for a file known by an incomplete pathname.
|
2004-11-03 13:51:07 +00:00
|
|
|
|
The prefixes are separated by `\fB:\fP'.
|
|
|
|
|
(Similarly one has \fBCDPATH\fP used by some shells to find the target
|
2007-05-12 09:06:04 +00:00
|
|
|
|
of a change directory command, \fBMANPATH\fP used by
|
|
|
|
|
.BR man (1)
|
|
|
|
|
to
|
2004-11-03 13:51:07 +00:00
|
|
|
|
find manual pages, etc.)
|
|
|
|
|
.TP
|
|
|
|
|
.B PWD
|
2007-04-12 22:42:49 +00:00
|
|
|
|
The current working directory.
|
|
|
|
|
Set by some shells.
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.TP
|
|
|
|
|
.B SHELL
|
2006-02-12 22:15:41 +00:00
|
|
|
|
The pathname of the user's login shell.
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.TP
|
|
|
|
|
.B TERM
|
|
|
|
|
The terminal type for which output is to be prepared.
|
|
|
|
|
.TP
|
|
|
|
|
.B PAGER
|
|
|
|
|
The user's preferred utility to display text files.
|
|
|
|
|
.TP
|
|
|
|
|
.BR EDITOR / VISUAL
|
|
|
|
|
The user's preferred utility to edit text files.
|
2005-12-06 13:13:48 +00:00
|
|
|
|
.\" .TP
|
|
|
|
|
.\" .B BROWSER
|
|
|
|
|
.\" The user's preferred utility to browse URLs. Sequence of colon-separated
|
|
|
|
|
.\" browser commands. See http://www.catb.org/~esr/BROWSER/ .
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.PP
|
|
|
|
|
Further names may be placed in the environment by the \fBexport\fP
|
|
|
|
|
command and `name=value' in
|
|
|
|
|
.BR sh (1),
|
|
|
|
|
or by the \fBsetenv\fP command if you use
|
|
|
|
|
.BR csh (1).
|
|
|
|
|
Arguments may also be placed in the
|
|
|
|
|
environment at the point of an
|
|
|
|
|
.BR exec (3).
|
|
|
|
|
A C program can manipulate its environment using the functions
|
|
|
|
|
.BR getenv (3),
|
|
|
|
|
.BR putenv (3),
|
|
|
|
|
.BR setenv (3),
|
|
|
|
|
and
|
|
|
|
|
.BR unsetenv (3).
|
|
|
|
|
|
|
|
|
|
Note that the behaviour of many programs and library routines is
|
|
|
|
|
influenced by the presence or value of certain environment variables.
|
|
|
|
|
A random collection:
|
|
|
|
|
.LP
|
|
|
|
|
The variables
|
2007-04-12 22:42:49 +00:00
|
|
|
|
.BR LANG ", " LANGUAGE ", " NLSPATH ", " LOCPATH ", "
|
2006-12-27 03:54:41 +00:00
|
|
|
|
.BR LC_ALL ", " LC_MESSAGES ", "
|
2004-11-03 13:51:07 +00:00
|
|
|
|
etc. influence locale handling, cf.
|
|
|
|
|
.BR locale (5).
|
|
|
|
|
.LP
|
|
|
|
|
.B TMPDIR
|
|
|
|
|
influences the path prefix of names created by
|
2007-06-02 06:23:05 +00:00
|
|
|
|
.BR tmpnam (3)
|
|
|
|
|
and other routines, the temporary directory used by
|
2007-05-12 09:06:04 +00:00
|
|
|
|
.BR sort (1)
|
|
|
|
|
and other programs, etc.
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.LP
|
|
|
|
|
.BR LD_LIBRARY_PATH ", " LD_PRELOAD
|
|
|
|
|
and other LD_* variables influence
|
|
|
|
|
the behaviour of the dynamic loader/linker.
|
|
|
|
|
.LP
|
|
|
|
|
.B POSIXLY_CORRECT
|
|
|
|
|
makes certain programs and library routines follow
|
|
|
|
|
the prescriptions of POSIX.
|
|
|
|
|
.LP
|
2007-05-12 09:06:04 +00:00
|
|
|
|
The behaviour of
|
|
|
|
|
.BR malloc (3)
|
|
|
|
|
is influenced by MALLOC_* variables.
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.LP
|
|
|
|
|
The variable
|
|
|
|
|
.B HOSTALIASES
|
|
|
|
|
gives the name of a file containing aliases
|
2007-05-12 09:06:04 +00:00
|
|
|
|
to be used with
|
|
|
|
|
.BR gethostbyname (3).
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.LP
|
|
|
|
|
.BR TZ " and " TZDIR
|
|
|
|
|
give time zone information used by
|
|
|
|
|
.BR tzset (3)
|
|
|
|
|
and through that by functions like
|
2007-06-01 05:51:12 +00:00
|
|
|
|
.BR ctime (3),
|
|
|
|
|
.BR localtime (3),
|
|
|
|
|
.BR mktime (3),
|
|
|
|
|
.BR strftime (3).
|
2004-11-03 13:51:07 +00:00
|
|
|
|
See also
|
2007-06-01 05:51:12 +00:00
|
|
|
|
.BR tzselect (8).
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.LP
|
|
|
|
|
.B TERMCAP
|
|
|
|
|
gives information on how to address a given terminal
|
|
|
|
|
(or gives the name of a file containing such information).
|
|
|
|
|
.LP
|
|
|
|
|
.BR COLUMNS " and " LINES
|
|
|
|
|
tell applications about the window size, possibly overriding the actual size.
|
|
|
|
|
.LP
|
|
|
|
|
.BR PRINTER " or " LPDEST
|
2007-04-12 22:42:49 +00:00
|
|
|
|
may specify the desired printer to use.
|
|
|
|
|
See
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.BR lpr (1).
|
|
|
|
|
.LP
|
|
|
|
|
Etc.
|
|
|
|
|
.SH BUGS
|
2007-04-12 22:42:49 +00:00
|
|
|
|
Clearly there is a security risk here.
|
|
|
|
|
Many a system command has been
|
2004-11-03 13:51:07 +00:00
|
|
|
|
tricked into mischief by a user who specified unusual values for
|
|
|
|
|
.BR IFS " or " LD_LIBRARY_PATH .
|
|
|
|
|
|
|
|
|
|
There is also the risk of name space pollution.
|
|
|
|
|
Programs like
|
|
|
|
|
.I make
|
|
|
|
|
and
|
|
|
|
|
.I autoconf
|
|
|
|
|
allow overriding of default utility names from the
|
|
|
|
|
environment with similarly named variables in all caps.
|
|
|
|
|
Thus one uses
|
|
|
|
|
.B CC
|
|
|
|
|
to select the desired C compiler (and similarly
|
|
|
|
|
.BR MAKE ,
|
|
|
|
|
.BR AR ,
|
|
|
|
|
.BR AS ,
|
|
|
|
|
.BR FC ,
|
|
|
|
|
.BR LD ,
|
|
|
|
|
.BR LEX ,
|
|
|
|
|
.BR RM ,
|
|
|
|
|
.BR YACC ,
|
|
|
|
|
etc.).
|
|
|
|
|
However, in some traditional uses such an environment variable
|
|
|
|
|
gives options for the program instead of a pathname.
|
|
|
|
|
Thus, one has
|
|
|
|
|
.BR MORE ,
|
|
|
|
|
.BR LESS ,
|
|
|
|
|
and
|
|
|
|
|
.BR GZIP .
|
|
|
|
|
Such usage is considered mistaken, and to be avoided in new
|
2007-04-12 22:42:49 +00:00
|
|
|
|
programs.
|
|
|
|
|
The authors of
|
2004-11-03 13:51:07 +00:00
|
|
|
|
.I gzip
|
|
|
|
|
should consider renaming their option to
|
|
|
|
|
.BR GZIP_OPT .
|
|
|
|
|
.SH "SEE ALSO"
|
|
|
|
|
.BR bash (1),
|
|
|
|
|
.BR csh (1),
|
|
|
|
|
.BR login (1),
|
|
|
|
|
.BR sh (1),
|
|
|
|
|
.BR tcsh (1),
|
|
|
|
|
.BR execve (2),
|
|
|
|
|
.BR clearenv (3),
|
|
|
|
|
.BR exec (3),
|
|
|
|
|
.BR getenv (3),
|
|
|
|
|
.BR putenv (3),
|
|
|
|
|
.BR setenv (3),
|
|
|
|
|
.BR unsetenv (3),
|
|
|
|
|
.BR locale (5)
|