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