3 <!DOCTYPE refentry PUBLIC
"-//OASIS//DTD DocBook XML V4.5//EN"
4 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
6 SPDX-License-Identifier: LGPL-2.1+
8 Copyright © 2016 Red Hat, Inc.
10 <refentry id=
"environment.d" conditional='ENABLE_ENVIRONMENT_D'
11 xmlns:
xi=
"http://www.w3.org/2001/XInclude">
14 <title>environment.d
</title>
15 <productname>systemd
</productname>
19 <refentrytitle>environment.d
</refentrytitle>
20 <manvolnum>5</manvolnum>
24 <refname>environment.d
</refname>
25 <refpurpose>Definition of user session environment
</refpurpose>
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>
37 <title>Description
</title>
39 <para>The
<filename>environment.d
</filename> directories contain a list of
"global" environment
40 variable assignments for the user environment.
41 <citerefentry><refentrytitle>systemd-environment-d-generator
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
42 parses them and updates the environment exported by the systemd user instance to the services it
45 <para>It is recommended to use numerical prefixes for file names to simplify ordering.
</para>
47 <para>For backwards compatibility, a symlink to
<filename>/etc/environment
</filename> is
48 installed, so this file is also parsed.
</para>
51 <xi:include href=
"standard-conf.xml" xpointer=
"confd" />
54 <title>Configuration Format
</title>
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>
60 and
<literal>$OTHER_KEY
</literal> format. It is also possible to use
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>,
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>
71 <para>Each
<replaceable>KEY
</replaceable> must be a valid variable name. Empty lines
72 and lines beginning with the comment character
<literal>#
</literal> are ignored.
</para>
75 <title>Example
</title>
77 <title>Setup environment to allow access to a program installed in
78 <filename noindex='true'
>/opt/foo
</filename></title>
80 <para><filename>/etc/environment.d/
60-foo.conf
</filename>:
83 FOO_DEBUG=force-software-gl,log-verbose
84 PATH=/opt/foo/bin:$PATH
85 LD_LIBRARY_PATH=/opt/foo/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
86 XDG_DATA_DIRS=/opt/foo/share:${XDG_DATA_DIRS:-/usr/local/share/:/usr/share/}
93 <title>See Also
</title>
95 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
96 <citerefentry><refentrytitle>systemd-environment-d-generator
</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
97 <citerefentry><refentrytitle>systemd.environment-generator
</refentrytitle><manvolnum>7</manvolnum></citerefentry>