2016-07-29 17:52:55 +00:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
<!--*-nxml-*-->
|
2019-03-14 13:40:58 +00:00
|
|
|
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
|
|
|
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
|
2016-07-29 17:52:55 +00:00
|
|
|
<!--
|
2020-11-09 04:23:58 +00:00
|
|
|
SPDX-License-Identifier: LGPL-2.1-or-later
|
2017-11-18 16:22:32 +00:00
|
|
|
|
2018-06-12 17:00:24 +00:00
|
|
|
Copyright © 2016 Red Hat, Inc.
|
2016-07-29 17:52:55 +00:00
|
|
|
-->
|
2017-04-28 12:22:17 +00:00
|
|
|
<refentry id="environment.d" conditional='ENABLE_ENVIRONMENT_D'
|
|
|
|
xmlns:xi="http://www.w3.org/2001/XInclude">
|
2016-07-29 17:52:55 +00:00
|
|
|
|
|
|
|
<refentryinfo>
|
|
|
|
<title>environment.d</title>
|
|
|
|
<productname>systemd</productname>
|
|
|
|
</refentryinfo>
|
|
|
|
|
|
|
|
<refmeta>
|
|
|
|
<refentrytitle>environment.d</refentrytitle>
|
|
|
|
<manvolnum>5</manvolnum>
|
|
|
|
</refmeta>
|
|
|
|
|
|
|
|
<refnamediv>
|
|
|
|
<refname>environment.d</refname>
|
2020-07-16 07:25:22 +00:00
|
|
|
<refpurpose>Definition of user service environment</refpurpose>
|
2016-07-29 17:52:55 +00:00
|
|
|
</refnamediv>
|
|
|
|
|
|
|
|
<refsynopsisdiv>
|
|
|
|
<para><filename>~/.config/environment.d/*.conf</filename></para>
|
|
|
|
<para><filename>/etc/environment.d/*.conf</filename></para>
|
|
|
|
<para><filename>/run/environment.d/*.conf</filename></para>
|
|
|
|
<para><filename>/usr/lib/environment.d/*.conf</filename></para>
|
|
|
|
<para><filename>/etc/environment</filename></para>
|
|
|
|
</refsynopsisdiv>
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
|
2020-07-16 07:26:55 +00:00
|
|
|
<para>Configuration files in the <filename>environment.d/</filename> directories contain lists of
|
|
|
|
environment variable assignments for services started by the systemd user instance.
|
2016-07-29 17:52:55 +00:00
|
|
|
<citerefentry><refentrytitle>systemd-environment-d-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>
|
2020-02-28 09:56:38 +00:00
|
|
|
parses them and updates the environment exported by the systemd user instance. See below for an
|
|
|
|
discussion of which processes inherit those variables.</para>
|
2016-07-29 17:52:55 +00:00
|
|
|
|
|
|
|
<para>It is recommended to use numerical prefixes for file names to simplify ordering.</para>
|
|
|
|
|
|
|
|
<para>For backwards compatibility, a symlink to <filename>/etc/environment</filename> is
|
|
|
|
installed, so this file is also parsed.</para>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<xi:include href="standard-conf.xml" xpointer="confd" />
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>Configuration Format</title>
|
|
|
|
|
|
|
|
<para>The configuration files contain a list of
|
|
|
|
<literal><replaceable>KEY</replaceable>=<replaceable>VALUE</replaceable></literal> environment
|
|
|
|
variable assignments, separated by newlines. The right hand side of these assignments may
|
|
|
|
reference previously defined environment variables, using the <literal>${OTHER_KEY}</literal>
|
2016-08-09 14:20:22 +00:00
|
|
|
and <literal>$OTHER_KEY</literal> format. It is also possible to use
|
|
|
|
<literal>${<replaceable>FOO</replaceable>:-<replaceable>DEFAULT_VALUE</replaceable>}</literal>
|
|
|
|
to expand in the same way as <literal>${<replaceable>FOO</replaceable>}</literal> unless the
|
|
|
|
expansion would be empty, in which case it expands to <replaceable>DEFAULT_VALUE</replaceable>,
|
|
|
|
and use
|
|
|
|
<literal>${<replaceable>FOO</replaceable>:+<replaceable>ALTERNATE_VALUE</replaceable>}</literal>
|
|
|
|
to expand to <replaceable>ALTERNATE_VALUE</replaceable> as long as
|
|
|
|
<literal>${<replaceable>FOO</replaceable>}</literal> would have expanded to a non-empty value.
|
|
|
|
No other elements of shell syntax are supported.</para>
|
2016-07-29 17:52:55 +00:00
|
|
|
|
2017-12-08 02:44:20 +00:00
|
|
|
<para>Each <replaceable>KEY</replaceable> must be a valid variable name. Empty lines
|
2017-02-18 03:56:28 +00:00
|
|
|
and lines beginning with the comment character <literal>#</literal> are ignored.</para>
|
|
|
|
|
2016-07-29 17:52:55 +00:00
|
|
|
<refsect2>
|
|
|
|
<title>Example</title>
|
|
|
|
<example>
|
|
|
|
<title>Setup environment to allow access to a program installed in
|
2019-11-21 19:22:12 +00:00
|
|
|
<filename index="false">/opt/foo</filename></title>
|
2016-07-29 17:52:55 +00:00
|
|
|
|
2020-09-29 08:04:12 +00:00
|
|
|
<para><filename index="false">/etc/environment.d/60-foo.conf</filename>:
|
2016-07-29 17:52:55 +00:00
|
|
|
</para>
|
|
|
|
<programlisting>
|
|
|
|
FOO_DEBUG=force-software-gl,log-verbose
|
2017-02-11 19:05:10 +00:00
|
|
|
PATH=/opt/foo/bin:$PATH
|
2017-05-11 02:23:54 +00:00
|
|
|
LD_LIBRARY_PATH=/opt/foo/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
|
2016-08-09 14:20:22 +00:00
|
|
|
XDG_DATA_DIRS=/opt/foo/share:${XDG_DATA_DIRS:-/usr/local/share/:/usr/share/}
|
2016-07-29 17:52:55 +00:00
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</refsect2>
|
|
|
|
</refsect1>
|
|
|
|
|
2020-02-28 09:56:38 +00:00
|
|
|
<refsect1>
|
|
|
|
<title>Applicability</title>
|
|
|
|
|
|
|
|
<para>Environment variables exported by the user manager (<command>systemd --user</command> instance
|
|
|
|
started in the <filename>user@<replaceable>uid</replaceable>.service</filename> system service) apply to
|
|
|
|
any services started by that manager. In particular, this may include services which run user shells. For
|
2020-07-16 07:26:38 +00:00
|
|
|
example in the GNOME environment, the graphical terminal emulator runs as the
|
2020-02-28 09:56:38 +00:00
|
|
|
<filename>gnome-terminal-server.service</filename> user unit, which in turn runs the user shell, so that
|
|
|
|
shell will inherit environment variables exported by the user manager. For other instances of the shell,
|
|
|
|
not launched by the user manager, the environment they inherit is defined by the program that starts
|
|
|
|
them. Hint: in general,
|
|
|
|
<citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
|
|
|
|
units contain programs launched by systemd, and
|
|
|
|
<citerefentry><refentrytitle>systemd.scope</refentrytitle><manvolnum>5</manvolnum></citerefentry>
|
|
|
|
units contain programs launched by something else.</para>
|
|
|
|
|
|
|
|
<para>Specifically, for ssh logins, the
|
|
|
|
<citerefentry project='die-net'><refentrytitle>sshd</refentrytitle><manvolnum>8</manvolnum></citerefentry>
|
|
|
|
service builds an environment that is a combination of variables forwarded from the remote system and
|
|
|
|
defined by <command>sshd</command>, see the discussion in
|
|
|
|
<citerefentry project='die-net'><refentrytitle>ssh</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
|
|
|
|
A graphical display session will have an analogous mechanism to define the environment. Note that some
|
|
|
|
managers query the systemd user instance for the exported environment and inject this configuration into
|
|
|
|
programs they start, using <command>systemctl show-environment</command> or the underlying D-Bus call.
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
2016-07-29 17:52:55 +00:00
|
|
|
<refsect1>
|
|
|
|
<title>See Also</title>
|
|
|
|
<para>
|
|
|
|
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
|
|
|
|
<citerefentry><refentrytitle>systemd-environment-d-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
|
|
|
|
<citerefentry><refentrytitle>systemd.environment-generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
</refentry>
|