{
    "content": [
        {
            "type": "text",
            "text": "# environ (man)\n\n## NAME\n\nenviron - user environment\n\n## SYNOPSIS\n\nextern char environ;\n\n## DESCRIPTION\n\nThe variable environ points to an array of pointers to strings called the \"environment\".  The\nlast  pointer  in  this array has the value NULL.  This array of strings is made available to\nthe process by the execve(2) call when a new program is started.  When  a  child  process  is\ncreated via fork(2), it inherits a copy of its parent's environment.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **NOTES**\n- **BUGS**\n- **SEE ALSO**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "environ",
        "section": "",
        "mode": "man",
        "summary": "environ - user environment",
        "synopsis": "extern char environ;",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [
            {
                "name": "bash",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/bash/1/json"
            },
            {
                "name": "csh",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/csh/1/json"
            },
            {
                "name": "env",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/env/1/json"
            },
            {
                "name": "login",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/login/1/json"
            },
            {
                "name": "printenv",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/printenv/1/json"
            },
            {
                "name": "sh",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/sh/1/json"
            },
            {
                "name": "su",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/su/1/json"
            },
            {
                "name": "tcsh",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/tcsh/1/json"
            },
            {
                "name": "execve",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/execve/2/json"
            },
            {
                "name": "clearenv",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/clearenv/3/json"
            },
            {
                "name": "exec",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/exec/3/json"
            },
            {
                "name": "getenv",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/getenv/3/json"
            },
            {
                "name": "putenv",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/putenv/3/json"
            },
            {
                "name": "setenv",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/setenv/3/json"
            },
            {
                "name": "unsetenv",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/unsetenv/3/json"
            },
            {
                "name": "locale",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/locale/7/json"
            },
            {
                "name": "ld.so",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/ld.so/8/json"
            },
            {
                "name": "pamenv",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/pamenv/8/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 114,
                "subsections": []
            },
            {
                "name": "NOTES",
                "lines": 12,
                "subsections": []
            },
            {
                "name": "BUGS",
                "lines": 10,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "environ - user environment\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "extern char environ;\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "The variable environ points to an array of pointers to strings called the \"environment\".  The\nlast  pointer  in  this array has the value NULL.  This array of strings is made available to\nthe process by the execve(2) call when a new program is started.  When  a  child  process  is\ncreated via fork(2), it inherits a copy of its parent's environment.\n\nBy convention, the strings in environ have the form \"name=value\".  The name is case-sensitive\nand  may not contain the character \"=\".  The value can be anything that can be represented as\na string.  The name and the value may not contain an embedded null byte ('\\0'), since this is\nassumed to terminate the string.\n\nEnvironment variables may be placed in the shell's  environment  by  the  export  command  in\nsh(1), or by the setenv command if you use csh(1).\n\nThe  initial  environment of the shell is populated in various ways, such as definitions from\n/etc/environment that are processed by pamenv(8) for all users at  login  time  (on  systems\nthat  employ pam(8)).  In addition, various shell initialization scripts, such as the system-\nwide /etc/profile script and per-user initializations script may include  commands  that  add\nvariables  to  the  shell's  environment; see the manual page of your preferred shell for de‐\ntails.\n\nBourne-style shells support the syntax\n\nNAME=value command\n\nto create an environment variable definition only in the scope of the process  that  executes\ncommand.  Multiple variable definitions, separated by white space, may precede command.\n\nArguments  may also be placed in the environment at the point of an exec(3).  A C program can\nmanipulate its environment using the  functions  getenv(3),  putenv(3),  setenv(3),  and  un‐\nsetenv(3).\n\nWhat follows is a list of environment variables typically seen on a system.  This list is in‐\ncomplete  and  includes  only common variables seen by average users in their day-to-day rou‐\ntine.  Environment variables specific to a particular program or library function  are  docu‐\nmented in the ENVIRONMENT section of the appropriate manual page.\n\nUSER   The  name  of  the  logged-in  user (used by some BSD-derived programs).  Set at login\ntime, see section NOTES below.\n\nLOGNAME\nThe name of the logged-in user (used by some System-V derived programs).  Set at login\ntime, see section NOTES below.\n\nHOME   A user's login directory.  Set at login time, see section NOTES below.\n\nLANG   The name of a locale to use for locale categories when not  overridden  by  LCALL  or\nmore specific environment variables such as LCCOLLATE, LCCTYPE, LCMESSAGES, LCMON‐\nETARY, LCNUMERIC, and LCTIME (see locale(7) for further details of the LC* environ‐\nment variables).\n\nPATH   The  sequence  of  directory  prefixes  that sh(1) and many other programs employ when\nsearching for an executable file that is specified as a simple filename (i.a., a path‐\nname that contains no slashes).  The prefixes are separated by colons (:).   The  list\nof prefixes is searched from beginning to end, by checking the pathname formed by con‐\ncatenating  a  prefix, a slash, and the filename, until a file with execute permission\nis found.\n\nAs a legacy feature, a zero-length prefix (specified as two  adjacent  colons,  or  an\ninitial  or  terminating  colon) is interpreted to mean the current working directory.\nHowever, use of this feature is deprecated, and POSIX notes that a conforming applica‐\ntion shall use an explicit pathname (e.g., .)  to specify the current  working  direc‐\ntory.\n\nAnalogously to PATH, one has CDPATH used by some shells to find the target of a change\ndirectory command, MANPATH used by man(1) to find manual pages, and so on.\n\nPWD    Absolute path to the current working directory; required to be partially canonical (no\n. or .. components).\n\nSHELL  The absolute pathname of the user's login shell.  Set at login time, see section NOTES\nbelow.\n\nTERM   The terminal type for which output is to be prepared.\n\nPAGER  The  user's  preferred utility to display text files.  Any string acceptable as a com‐\nmand-string operand to the sh -c command shall be valid.  If PAGER is null or  is  not\nset,  then  applications that launch a pager will default to a program such as less(1)\nor more(1).\n\nEDITOR/VISUAL\nThe user's preferred utility to edit text files.  Any  string  acceptable  as  a  com‐\nmandstring operand to the sh -c command shall be valid.\n\nNote that the behavior of many programs and library routines is influenced by the presence or\nvalue of certain environment variables.  Examples include the following:\n\n•  The  variables  LANG, LANGUAGE, NLSPATH, LOCPATH, LCALL, LCMESSAGES, and so on influence\nlocale handling; see catopen(3), gettext(3), and locale(7).\n\n•  TMPDIR influences the path prefix of names created by tempnam(3) and other  routines,  and\nthe temporary directory used by sort(1) and other programs.\n\n•  LDLIBRARYPATH,  LDPRELOAD,  and  other LD* variables influence the behavior of the dy‐\nnamic loader/linker.  See also ld.so(8).\n\n•  POSIXLYCORRECT makes certain programs and library routines follow  the  prescriptions  of\nPOSIX.\n\n•  The behavior of malloc(3) is influenced by MALLOC* variables.\n\n•  The variable HOSTALIASES gives the name of a file containing aliases to be used with geth‐\nostbyname(3).\n\n•  TZ and TZDIR give timezone information used by tzset(3) and through that by functions like\nctime(3), localtime(3), mktime(3), strftime(3).  See also tzselect(8).\n\n•  TERMCAP  gives information on how to address a given terminal (or gives the name of a file\ncontaining such information).\n\n•  COLUMNS and LINES tell applications about the window size, possibly overriding the  actual\nsize.\n\n•  PRINTER or LPDEST may specify the desired printer to use.  See lpr(1).\n",
                "subsections": []
            },
            "NOTES": {
                "content": "Historically  and  by  standard, environ must be declared in the user program.  However, as a\n(nonstandard) programmer convenience, environ is declared in the header  file  <unistd.h>  if\nthe GNUSOURCE feature test macro is defined (see featuretestmacros(7)).\n\nThe  prctl(2) PRSETMMENVSTART and PRSETMMENVEND operations can be used to control the\nlocation of the process's environment.\n\nThe HOME, LOGNAME, SHELL, and USER variables are set when the user is changed via  a  session\nmanagement  interface,  typically by a program such as login(1) from a user database (such as\npasswd(5)).  (Switching to the root user using su(1) may result in a mixed environment  where\nLOGNAME and USER are retained from old user; see the su(1) manual page.)\n",
                "subsections": []
            },
            "BUGS": {
                "content": "Clearly  there is a security risk here.  Many a system command has been tricked into mischief\nby a user who specified unusual values for IFS or LDLIBRARYPATH.\n\nThere is also the risk of name space pollution.  Programs like make and autoconf allow  over‐\nriding  of  default  utility names from the environment with similarly named variables in all\ncaps.  Thus one uses CC to select the desired C compiler (and similarly MAKE, AR, AS, FC, LD,\nLEX, RM, YACC, etc.).  However, in some traditional uses such an environment  variable  gives\noptions  for  the program instead of a pathname.  Thus, one has MORE and LESS.  Such usage is\nconsidered mistaken, and to be avoided in new programs.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "bash(1),  csh(1),  env(1),  login(1),  printenv(1),   sh(1),   su(1),   tcsh(1),   execve(2),\nclearenv(3),  exec(3),  getenv(3),  putenv(3),  setenv(3),  unsetenv(3), locale(7), ld.so(8),\npamenv(8)\n\nLinux man-pages 6.7                          2023-10-31                                   environ(7)",
                "subsections": []
            }
        }
    }
}