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