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