]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/runlevel.xml
tree-wide: remove Lennart's copyright lines
[thirdparty/systemd.git] / man / runlevel.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="runlevel"
10 xmlns:xi="http://www.w3.org/2001/XInclude"
11 conditional="ENABLE_UTMP">
12
13 <refentryinfo>
14 <title>runlevel</title>
15 <productname>systemd</productname>
16
17 <authorgroup>
18 <author>
19 <contrib>Developer</contrib>
20 <firstname>Lennart</firstname>
21 <surname>Poettering</surname>
22 <email>lennart@poettering.net</email>
23 </author>
24 </authorgroup>
25 </refentryinfo>
26
27 <refmeta>
28 <refentrytitle>runlevel</refentrytitle>
29 <manvolnum>8</manvolnum>
30 </refmeta>
31
32 <refnamediv>
33 <refname>runlevel</refname>
34 <refpurpose>Print previous and current SysV runlevel</refpurpose>
35 </refnamediv>
36
37 <refsynopsisdiv>
38 <cmdsynopsis>
39 <command>runlevel</command>
40 <arg choice="opt" rep="repeat">options</arg>
41 </cmdsynopsis>
42 </refsynopsisdiv>
43
44 <refsect1>
45 <title>Overview</title>
46
47 <para>"Runlevels" are an obsolete way to start and stop groups of
48 services used in SysV init. systemd provides a compatibility layer
49 that maps runlevels to targets, and associated binaries like
50 <command>runlevel</command>. Nevertheless, only one runlevel can
51 be "active" at a given time, while systemd can activate multiple
52 targets concurrently, so the mapping to runlevels is confusing
53 and only approximate. Runlevels should not be used in new code,
54 and are mostly useful as a shorthand way to refer the matching
55 systemd targets in kernel boot parameters.</para>
56
57 <table>
58 <title>Mapping between runlevels and systemd targets</title>
59 <tgroup cols='2' align='left' colsep='1' rowsep='1'>
60 <colspec colname="runlevel" />
61 <colspec colname="target" />
62 <thead>
63 <row>
64 <entry>Runlevel</entry>
65 <entry>Target</entry>
66 </row>
67 </thead>
68 <tbody>
69 <row>
70 <entry>0</entry>
71 <entry><filename>poweroff.target</filename></entry>
72 </row>
73 <row>
74 <entry>1</entry>
75 <entry><filename>rescue.target</filename></entry>
76 </row>
77 <row>
78 <entry>2, 3, 4</entry>
79 <entry><filename>multi-user.target</filename></entry>
80 </row>
81 <row>
82 <entry>5</entry>
83 <entry><filename>graphical.target</filename></entry>
84 </row>
85 <row>
86 <entry>6</entry>
87 <entry><filename>reboot.target</filename></entry>
88 </row>
89 </tbody>
90 </tgroup>
91 </table>
92 </refsect1>
93
94 <refsect1>
95 <title>Description</title>
96
97 <para><command>runlevel</command> prints the previous and current
98 SysV runlevel if they are known.</para>
99
100 <para>The two runlevel characters are separated by a single space
101 character. If a runlevel cannot be determined, N is printed
102 instead. If neither can be determined, the word "unknown" is
103 printed.</para>
104
105 <para>Unless overridden in the environment, this will check the
106 utmp database for recent runlevel changes.</para>
107 </refsect1>
108
109 <refsect1>
110 <title>Options</title>
111
112 <para>The following option is understood:</para>
113
114 <variablelist>
115 <varlistentry>
116 <term><option>--help</option></term>
117
118 <xi:include href="standard-options.xml" xpointer="help-text" />
119 </varlistentry>
120 </variablelist>
121
122 </refsect1>
123
124 <refsect1>
125 <title>Exit status</title>
126
127 <para>If one or both runlevels could be determined, 0 is returned,
128 a non-zero failure code otherwise.</para>
129
130 </refsect1>
131
132 <refsect1>
133 <title>Environment</title>
134
135 <variablelist class='environment-variables'>
136 <varlistentry>
137 <term><varname>$RUNLEVEL</varname></term>
138
139 <listitem><para>If <varname>$RUNLEVEL</varname> is set,
140 <command>runlevel</command> will print this value as current
141 runlevel and ignore utmp.</para></listitem>
142 </varlistentry>
143
144 <varlistentry>
145 <term><varname>$PREVLEVEL</varname></term>
146
147 <listitem><para>If <varname>$PREVLEVEL</varname> is set,
148 <command>runlevel</command> will print this value as previous
149 runlevel and ignore utmp.</para></listitem>
150 </varlistentry>
151 </variablelist>
152 </refsect1>
153
154 <refsect1>
155 <title>Files</title>
156
157 <variablelist>
158 <varlistentry>
159 <term><filename>/run/utmp</filename></term>
160
161 <listitem><para>The utmp database <command>runlevel</command> reads the previous and current runlevel
162 from.</para></listitem>
163 </varlistentry>
164 </variablelist>
165 </refsect1>
166
167 <refsect1>
168 <title>See Also</title>
169 <para>
170 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
171 <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
172 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
173 </para>
174 </refsect1>
175
176 </refentry>