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