1<?xml version='1.0'?> <!--*-nxml-*-->
2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3  "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
5
6<refentry id="systemd.target">
7  <refentryinfo>
8    <title>systemd.target</title>
9    <productname>systemd</productname>
10  </refentryinfo>
11
12  <refmeta>
13    <refentrytitle>systemd.target</refentrytitle>
14    <manvolnum>5</manvolnum>
15  </refmeta>
16
17  <refnamediv>
18    <refname>systemd.target</refname>
19    <refpurpose>Target unit configuration</refpurpose>
20  </refnamediv>
21
22  <refsynopsisdiv>
23    <para><filename><replaceable>target</replaceable>.target</filename></para>
24  </refsynopsisdiv>
25
26  <refsect1>
27    <title>Description</title>
28
29    <para>A unit configuration file whose name ends in
30    <literal>.target</literal> encodes information about a target unit
31    of systemd, which is used for grouping units and as well-known
32    synchronization points during start-up.</para>
33
34    <para>This unit type has no specific options. See
35    <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
36    for the common options of all unit configuration files. The common
37    configuration items are configured in the generic [Unit] and
38    [Install] sections. A separate [Target] section does not exist,
39    since no target-specific options may be configured.</para>
40
41    <para>Target units do not offer any additional functionality on
42    top of the generic functionality provided by units. They exist
43    merely to group units via dependencies (useful as boot targets),
44    and to establish standardized names for synchronization points
45    used in dependencies between units. Among other things, target
46    units are a more flexible replacement for SysV runlevels in the
47    classic SysV init system. (And for compatibility reasons special
48    target units such as <filename>runlevel3.target</filename> exist
49    which are used by the SysV runlevel compatibility code in systemd.
50    See
51    <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>
52    for details).</para>
53  </refsect1>
54
55  <refsect1>
56    <title>Automatic Dependencies</title>
57
58    <refsect2>
59      <title>Implicit Dependencies</title>
60
61      <para>There are no implicit dependencies for target units.</para>
62    </refsect2>
63
64    <refsect2>
65      <title>Default Dependencies</title>
66
67      <para>The following dependencies are added unless
68      <varname>DefaultDependencies=no</varname> is set:</para>
69
70      <itemizedlist>
71        <listitem><para>Target units will automatically complement all
72        configured dependencies of type <varname>Wants=</varname> or
73        <varname>Requires=</varname> with dependencies of type
74        <varname>After=</varname> unless <varname>DefaultDependencies=no</varname>
75        is set in the specified units. Note that <varname>Wants=</varname> or
76        <varname>Requires=</varname> must be defined in the target unit itself — if
77        you for example define <varname>Wants=</varname>some.target in
78        some.service, the automatic ordering will not be added.</para></listitem>
79
80        <listitem><para>Target units automatically gain <varname>Conflicts=</varname>
81        and <varname>Before=</varname> dependencies against
82        <filename>shutdown.target</filename>.</para></listitem>
83      </itemizedlist>
84    </refsect2>
85  </refsect1>
86
87  <refsect1>
88    <title>Options</title>
89
90    <para>Target unit files may include [Unit] and [Install] sections, which are described in
91    <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
92    No options specific to this file type are supported.</para>
93  </refsect1>
94
95  <refsect1>
96    <title>Example</title>
97
98    <example>
99      <title>Simple standalone target</title>
100
101      <programlisting># emergency-net.target
102
103[Unit]
104Description=Emergency Mode with Networking
105Requires=emergency.target systemd-networkd.service
106After=emergency.target systemd-networkd.service
107AllowIsolate=yes</programlisting>
108
109      <para>When adding dependencies to other units, it's important to check if they set
110      <varname>DefaultDependencies=</varname>. Service units, unless they set
111      <varname>DefaultDependencies=no</varname>, automatically get a dependency on
112      <filename>sysinit.target</filename>. In this case, both
113      <filename>emergency.target</filename> and <filename>systemd-networkd.service</filename>
114      have <varname>DefaultDependencies=no</varname>, so they are suitable for use
115      in this target, and do not pull in <filename>sysinit.target</filename>.</para>
116
117      <para>You can now switch into this emergency mode by running <varname>systemctl
118      isolate emergency-net.target</varname> or by passing the option
119      <varname>systemd.unit=emergency-net.target</varname> on the kernel command
120      line.</para>
121
122      <para>Other units can have <varname>WantedBy=emergency-net.target</varname> in the
123      <varname>[Install]</varname> section. After they are enabled using
124      <command>systemctl enable</command>, they will be started before
125      <varname>emergency-net.target</varname> is started. It is also possible to add
126      arbitrary units as dependencies of <filename>emergency.target</filename> without
127      modifying them by using <command>systemctl add-wants</command>.
128      </para>
129    </example>
130  </refsect1>
131
132  <refsect1>
133      <title>See Also</title>
134      <para>
135        <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
136        <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
137        <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
138        <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
139        <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>
140      </para>
141  </refsect1>
142
143</refentry>
144