]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/environment.d.xml
Merge pull request #5801 from keszybz/help-error
[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 This file is part of systemd.
6
7 Copyright 2016 Red Hat, Inc.
8 Copyright 2017 Zbigniew Jędrzejewski-Szmek
9
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 -->
23 <refentry id="environment.d" conditional='ENABLE_ENVIRONMENT_D'
24 xmlns:xi="http://www.w3.org/2001/XInclude">
25
26 <refentryinfo>
27 <title>environment.d</title>
28 <productname>systemd</productname>
29
30 <authorgroup>
31 <author>
32 <contrib>Developer</contrib>
33 <firstname>Ray</firstname>
34 <surname>Strode</surname>
35 <email>rstrode@redhat.com</email>
36 </author>
37 </authorgroup>
38 </refentryinfo>
39
40 <refmeta>
41 <refentrytitle>environment.d</refentrytitle>
42 <manvolnum>5</manvolnum>
43 </refmeta>
44
45 <refnamediv>
46 <refname>environment.d</refname>
47 <refpurpose>Definition of user session environment</refpurpose>
48 </refnamediv>
49
50 <refsynopsisdiv>
51 <para><filename>~/.config/environment.d/*.conf</filename></para>
52 <para><filename>/etc/environment.d/*.conf</filename></para>
53 <para><filename>/run/environment.d/*.conf</filename></para>
54 <para><filename>/usr/lib/environment.d/*.conf</filename></para>
55 <para><filename>/etc/environment</filename></para>
56 </refsynopsisdiv>
57
58 <refsect1>
59 <title>Description</title>
60
61 <para>The <filename>environment.d</filename> directories contain a list of "global" environment
62 variable assignments for the user environment.
63 <citerefentry><refentrytitle>systemd-environment-d-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>
64 parses them and updates the environment exported by the systemd user instance to the services it
65 starts.</para>
66
67 <para>It is recommended to use numerical prefixes for file names to simplify ordering.</para>
68
69 <para>For backwards compatibility, a symlink to <filename>/etc/environment</filename> is
70 installed, so this file is also parsed.</para>
71 </refsect1>
72
73 <xi:include href="standard-conf.xml" xpointer="confd" />
74
75 <refsect1>
76 <title>Configuration Format</title>
77
78 <para>The configuration files contain a list of
79 <literal><replaceable>KEY</replaceable>=<replaceable>VALUE</replaceable></literal> environment
80 variable assignments, separated by newlines. The right hand side of these assignments may
81 reference previously defined environment variables, using the <literal>${OTHER_KEY}</literal>
82 and <literal>$OTHER_KEY</literal> format. It is also possible to use
83
84 <literal>${<replaceable>FOO</replaceable>:-<replaceable>DEFAULT_VALUE</replaceable>}</literal>
85 to expand in the same way as <literal>${<replaceable>FOO</replaceable>}</literal> unless the
86 expansion would be empty, in which case it expands to <replaceable>DEFAULT_VALUE</replaceable>,
87 and use
88 <literal>${<replaceable>FOO</replaceable>:+<replaceable>ALTERNATE_VALUE</replaceable>}</literal>
89 to expand to <replaceable>ALTERNATE_VALUE</replaceable> as long as
90 <literal>${<replaceable>FOO</replaceable>}</literal> would have expanded to a non-empty value.
91 No other elements of shell syntax are supported.</para>
92
93 <para>Each<replaceable>KEY</replaceable> must be a valid variable name. Empty lines
94 and lines beginning with the comment character <literal>#</literal> are ignored.</para>
95
96 <refsect2>
97 <title>Example</title>
98 <example>
99 <title>Setup environment to allow access to a program installed in
100 <filename noindex='true'>/opt/foo</filename></title>
101
102 <para><filename>/etc/environment.d/60-foo.conf</filename>:
103 </para>
104 <programlisting>
105 FOO_DEBUG=force-software-gl,log-verbose
106 PATH=/opt/foo/bin:$PATH
107 LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}/opt/foo/lib
108 XDG_DATA_DIRS=/opt/foo/share:${XDG_DATA_DIRS:-/usr/local/share/:/usr/share/}
109 </programlisting>
110 </example>
111 </refsect2>
112 </refsect1>
113
114 <refsect1>
115 <title>See Also</title>
116 <para>
117 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
118 <citerefentry><refentrytitle>systemd-environment-d-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
119 <citerefentry><refentrytitle>systemd.environment-generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>
120 </para>
121 </refsect1>
122
123 </refentry>