]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/systemd.target.xml
util: rename socket_protocol_{from,to}_name() to ip_protocol_{from,to}_name()
[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 and <varname>Before=</varname> dependencies against
85 <filename>shutdown.target</filename>.</para></listitem>
86 </itemizedlist>
87 </refsect2>
88 </refsect1>
89
90 <refsect1>
91 <title>Example</title>
92
93 <example>
94 <title>Simple standalone target</title>
95
96 <programlisting># emergency-net.target
97
98 [Unit]
99 Description=Emergency Mode with Networking
100 Requires=emergency.target systemd-networkd.service
101 After=emergency.target systemd-networkd.service
102 AllowIsolate=yes</programlisting>
103
104 <para>When adding dependencies to other units, it's important to check if they set
105 <varname>DefaultDependencies=</varname>. Service units, unless they set
106 <varname>DefaultDependencies=no</varname>, automatically get a dependency on
107 <filename>sysinit.target</filename>. In this case, both
108 <filename>emergency.target</filename> and <filename>systemd-networkd.service</filename>
109 have <varname>DefaultDependencies=no</varname>, so they are suitable for use
110 in this target, and do not pull in <filename>sysinit.target</filename>.</para>
111
112 <para>You can now switch into this emergency mode by running <varname>systemctl
113 isolate emergency-net.target</varname> or by passing the option
114 <varname>systemd.unit=emergency-net.target</varname> on the kernel command
115 line.</para>
116
117 <para>Other units can have <varname>WantedBy=emergency-net.target</varname> in the
118 <varname>[Install]</varname> section. After they are enabled using
119 <command>systemctl enable</command>, they will be started before
120 <varname>emergency-net.target</varname> is started. It is also possible to add
121 arbitrary units as dependencies of <filename>emergency.target</filename> without
122 modifying them by using <command>systemctl add-wants</command>.
123 </para>
124 </example>
125 </refsect1>
126
127 <refsect1>
128 <title>See Also</title>
129 <para>
130 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
131 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
132 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
133 <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
134 <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>
135 </para>
136 </refsect1>
137
138 </refentry>