]>
Commit | Line | Data |
---|---|---|
79d615d5 RS |
1 | <?xml version="1.0"?> |
2 | <!--*-nxml-*--> | |
3a54a157 | 3 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" |
eea10b26 | 4 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"> |
79d615d5 | 5 | <!-- |
db9ecf05 | 6 | SPDX-License-Identifier: LGPL-2.1-or-later |
572eb058 | 7 | |
96b2fb93 | 8 | Copyright © 2016 Red Hat, Inc. |
79d615d5 | 9 | --> |
232bd677 | 10 | <refentry id="environment.d" conditional='ENABLE_ENVIRONMENT_D' |
11 | xmlns:xi="http://www.w3.org/2001/XInclude"> | |
79d615d5 RS |
12 | |
13 | <refentryinfo> | |
14 | <title>environment.d</title> | |
15 | <productname>systemd</productname> | |
79d615d5 RS |
16 | </refentryinfo> |
17 | ||
18 | <refmeta> | |
19 | <refentrytitle>environment.d</refentrytitle> | |
20 | <manvolnum>5</manvolnum> | |
21 | </refmeta> | |
22 | ||
23 | <refnamediv> | |
24 | <refname>environment.d</refname> | |
a449b719 | 25 | <refpurpose>Definition of user service environment</refpurpose> |
79d615d5 RS |
26 | </refnamediv> |
27 | ||
28 | <refsynopsisdiv> | |
73e97bb0 ZJS |
29 | <para><simplelist> |
30 | <member><filename>~/.config/environment.d/*.conf</filename></member> | |
31 | <member><filename>/etc/environment.d/*.conf</filename></member> | |
32 | <member><filename>/run/environment.d/*.conf</filename></member> | |
33 | <member><filename>/usr/lib/environment.d/*.conf</filename></member> | |
34 | <member><filename>/etc/environment</filename></member> | |
35 | </simplelist></para> | |
79d615d5 RS |
36 | </refsynopsisdiv> |
37 | ||
38 | <refsect1> | |
39 | <title>Description</title> | |
40 | ||
3f13f915 | 41 | <para>Configuration files in the <filename>environment.d/</filename> directories contain lists of |
bebf6fcf | 42 | environment variable assignments passed to services started by the systemd user instance. |
79d615d5 | 43 | <citerefentry><refentrytitle>systemd-environment-d-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry> |
3ea2b113 ZJS |
44 | parses them and updates the environment exported by the systemd user instance. See below for an |
45 | discussion of which processes inherit those variables.</para> | |
79d615d5 RS |
46 | |
47 | <para>It is recommended to use numerical prefixes for file names to simplify ordering.</para> | |
48 | ||
49 | <para>For backwards compatibility, a symlink to <filename>/etc/environment</filename> is | |
50 | installed, so this file is also parsed.</para> | |
51 | </refsect1> | |
52 | ||
53 | <xi:include href="standard-conf.xml" xpointer="confd" /> | |
54 | ||
55 | <refsect1> | |
56 | <title>Configuration Format</title> | |
57 | ||
58 | <para>The configuration files contain a list of | |
59 | <literal><replaceable>KEY</replaceable>=<replaceable>VALUE</replaceable></literal> environment | |
60 | variable assignments, separated by newlines. The right hand side of these assignments may | |
61 | reference previously defined environment variables, using the <literal>${OTHER_KEY}</literal> | |
b82f58bf | 62 | and <literal>$OTHER_KEY</literal> format. It is also possible to use |
b82f58bf RS |
63 | <literal>${<replaceable>FOO</replaceable>:-<replaceable>DEFAULT_VALUE</replaceable>}</literal> |
64 | to expand in the same way as <literal>${<replaceable>FOO</replaceable>}</literal> unless the | |
65 | expansion would be empty, in which case it expands to <replaceable>DEFAULT_VALUE</replaceable>, | |
66 | and use | |
67 | <literal>${<replaceable>FOO</replaceable>:+<replaceable>ALTERNATE_VALUE</replaceable>}</literal> | |
68 | to expand to <replaceable>ALTERNATE_VALUE</replaceable> as long as | |
69 | <literal>${<replaceable>FOO</replaceable>}</literal> would have expanded to a non-empty value. | |
70 | No other elements of shell syntax are supported.</para> | |
79d615d5 | 71 | |
164147c3 | 72 | <para>Each <replaceable>KEY</replaceable> must be a valid variable name. Empty lines |
184d1904 ZJS |
73 | and lines beginning with the comment character <literal>#</literal> are ignored.</para> |
74 | ||
79d615d5 RS |
75 | <refsect2> |
76 | <title>Example</title> | |
77 | <example> | |
78 | <title>Setup environment to allow access to a program installed in | |
b0343f8c | 79 | <filename index="false">/opt/foo</filename></title> |
79d615d5 | 80 | |
211c99c7 | 81 | <para><filename index="false">/etc/environment.d/60-foo.conf</filename>: |
79d615d5 RS |
82 | </para> |
83 | <programlisting> | |
84 | FOO_DEBUG=force-software-gl,log-verbose | |
ccad1fd0 | 85 | PATH=/opt/foo/bin:$PATH |
af92daeb | 86 | LD_LIBRARY_PATH=/opt/foo/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} |
b82f58bf | 87 | XDG_DATA_DIRS=/opt/foo/share:${XDG_DATA_DIRS:-/usr/local/share/:/usr/share/} |
79d615d5 RS |
88 | </programlisting> |
89 | </example> | |
90 | </refsect2> | |
91 | </refsect1> | |
92 | ||
3ea2b113 ZJS |
93 | <refsect1> |
94 | <title>Applicability</title> | |
95 | ||
bebf6fcf LP |
96 | <para>Environment variables exported by the user service manager (<command>systemd --user</command> |
97 | instance started in the <filename>user@<replaceable>uid</replaceable>.service</filename> system service) | |
98 | are passed to any services started by that service manager. In particular, this may include services | |
99 | which run user shells. For example in the GNOME environment, the graphical terminal emulator runs as the | |
3ea2b113 ZJS |
100 | <filename>gnome-terminal-server.service</filename> user unit, which in turn runs the user shell, so that |
101 | shell will inherit environment variables exported by the user manager. For other instances of the shell, | |
bebf6fcf LP |
102 | not launched by the user service manager, the environment they inherit is defined by the program that |
103 | starts them. Hint: in general, | |
104 | <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry> units | |
105 | contain programs launched by systemd, and | |
106 | <citerefentry><refentrytitle>systemd.scope</refentrytitle><manvolnum>5</manvolnum></citerefentry> units | |
107 | contain programs launched by something else.</para> | |
108 | ||
109 | <para>Note that these files do not affect the environment block of the service manager itself, but | |
110 | exclusively the environment blocks passed to the services it manages. Environment variables set that way | |
111 | thus cannot be used to influence behaviour of the service manager. In order to make changes to the | |
112 | service manager's environment block the environment must be modified before the user's service manager is | |
113 | invoked, for example from the system service manager or via a PAM module.</para> | |
3ea2b113 ZJS |
114 | |
115 | <para>Specifically, for ssh logins, the | |
116 | <citerefentry project='die-net'><refentrytitle>sshd</refentrytitle><manvolnum>8</manvolnum></citerefentry> | |
117 | service builds an environment that is a combination of variables forwarded from the remote system and | |
118 | defined by <command>sshd</command>, see the discussion in | |
119 | <citerefentry project='die-net'><refentrytitle>ssh</refentrytitle><manvolnum>1</manvolnum></citerefentry>. | |
120 | A graphical display session will have an analogous mechanism to define the environment. Note that some | |
121 | managers query the systemd user instance for the exported environment and inject this configuration into | |
122 | programs they start, using <command>systemctl show-environment</command> or the underlying D-Bus call. | |
123 | </para> | |
124 | </refsect1> | |
125 | ||
79d615d5 RS |
126 | <refsect1> |
127 | <title>See Also</title> | |
13a69c12 DT |
128 | <para><simplelist type="inline"> |
129 | <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> | |
130 | <member><citerefentry><refentrytitle>systemd-environment-d-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry></member> | |
131 | <member><citerefentry><refentrytitle>systemd.environment-generator</refentrytitle><manvolnum>7</manvolnum></citerefentry></member> | |
132 | </simplelist></para> | |
79d615d5 RS |
133 | </refsect1> |
134 | ||
135 | </refentry> |