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