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