]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/environment.d.xml
e399bbd6fb49efb6f95701bbdcabe34f4fbcc4e9
[thirdparty/systemd.git] / man / environment.d.xml
1 <?xml version="1.0"?>
2 <!--*-nxml-*-->
3 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4 <!--
5 SPDX-License-Identifier: LGPL-2.1+
6
7 Copyright 2016 Red Hat, Inc.
8 Copyright 2017 Zbigniew Jędrzejewski-Szmek
9 -->
10 <refentry id="environment.d" conditional='ENABLE_ENVIRONMENT_D'
11 xmlns:xi="http://www.w3.org/2001/XInclude">
12
13 <refentryinfo>
14 <title>environment.d</title>
15 <productname>systemd</productname>
16
17 <authorgroup>
18 <author>
19 <contrib>Developer</contrib>
20 <firstname>Ray</firstname>
21 <surname>Strode</surname>
22 <email>rstrode@redhat.com</email>
23 </author>
24 </authorgroup>
25 </refentryinfo>
26
27 <refmeta>
28 <refentrytitle>environment.d</refentrytitle>
29 <manvolnum>5</manvolnum>
30 </refmeta>
31
32 <refnamediv>
33 <refname>environment.d</refname>
34 <refpurpose>Definition of user session environment</refpurpose>
35 </refnamediv>
36
37 <refsynopsisdiv>
38 <para><filename>~/.config/environment.d/*.conf</filename></para>
39 <para><filename>/etc/environment.d/*.conf</filename></para>
40 <para><filename>/run/environment.d/*.conf</filename></para>
41 <para><filename>/usr/lib/environment.d/*.conf</filename></para>
42 <para><filename>/etc/environment</filename></para>
43 </refsynopsisdiv>
44
45 <refsect1>
46 <title>Description</title>
47
48 <para>The <filename>environment.d</filename> directories contain a list of "global" environment
49 variable assignments for the user environment.
50 <citerefentry><refentrytitle>systemd-environment-d-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>
51 parses them and updates the environment exported by the systemd user instance to the services it
52 starts.</para>
53
54 <para>It is recommended to use numerical prefixes for file names to simplify ordering.</para>
55
56 <para>For backwards compatibility, a symlink to <filename>/etc/environment</filename> is
57 installed, so this file is also parsed.</para>
58 </refsect1>
59
60 <xi:include href="standard-conf.xml" xpointer="confd" />
61
62 <refsect1>
63 <title>Configuration Format</title>
64
65 <para>The configuration files contain a list of
66 <literal><replaceable>KEY</replaceable>=<replaceable>VALUE</replaceable></literal> environment
67 variable assignments, separated by newlines. The right hand side of these assignments may
68 reference previously defined environment variables, using the <literal>${OTHER_KEY}</literal>
69 and <literal>$OTHER_KEY</literal> format. It is also possible to use
70
71 <literal>${<replaceable>FOO</replaceable>:-<replaceable>DEFAULT_VALUE</replaceable>}</literal>
72 to expand in the same way as <literal>${<replaceable>FOO</replaceable>}</literal> unless the
73 expansion would be empty, in which case it expands to <replaceable>DEFAULT_VALUE</replaceable>,
74 and use
75 <literal>${<replaceable>FOO</replaceable>:+<replaceable>ALTERNATE_VALUE</replaceable>}</literal>
76 to expand to <replaceable>ALTERNATE_VALUE</replaceable> as long as
77 <literal>${<replaceable>FOO</replaceable>}</literal> would have expanded to a non-empty value.
78 No other elements of shell syntax are supported.</para>
79
80 <para>Each <replaceable>KEY</replaceable> must be a valid variable name. Empty lines
81 and lines beginning with the comment character <literal>#</literal> are ignored.</para>
82
83 <refsect2>
84 <title>Example</title>
85 <example>
86 <title>Setup environment to allow access to a program installed in
87 <filename noindex='true'>/opt/foo</filename></title>
88
89 <para><filename>/etc/environment.d/60-foo.conf</filename>:
90 </para>
91 <programlisting>
92 FOO_DEBUG=force-software-gl,log-verbose
93 PATH=/opt/foo/bin:$PATH
94 LD_LIBRARY_PATH=/opt/foo/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
95 XDG_DATA_DIRS=/opt/foo/share:${XDG_DATA_DIRS:-/usr/local/share/:/usr/share/}
96 </programlisting>
97 </example>
98 </refsect2>
99 </refsect1>
100
101 <refsect1>
102 <title>See Also</title>
103 <para>
104 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
105 <citerefentry><refentrytitle>systemd-environment-d-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
106 <citerefentry><refentrytitle>systemd.environment-generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>
107 </para>
108 </refsect1>
109
110 </refentry>