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