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">
6 SPDX-License-Identifier: LGPL-2.1+
8 This file is part of systemd.
10 Copyright 2010 Lennart Poettering
12 systemd is free software; you can redistribute it and/or modify it
13 under the terms of the GNU Lesser General Public License as published by
14 the Free Software Foundation; either version 2.1 of the License, or
15 (at your option) any later version.
17 systemd is distributed in the hope that it will be useful, but
18 WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Lesser General Public License for more details.
22 You should have received a copy of the GNU Lesser General Public License
23 along with systemd; If not, see <http://www.gnu.org/licenses/>.
26 <refentry id=
"runlevel"
27 xmlns:
xi=
"http://www.w3.org/2001/XInclude"
28 conditional=
"ENABLE_UTMP">
31 <title>runlevel
</title>
32 <productname>systemd
</productname>
36 <contrib>Developer
</contrib>
37 <firstname>Lennart
</firstname>
38 <surname>Poettering
</surname>
39 <email>lennart@poettering.net
</email>
45 <refentrytitle>runlevel
</refentrytitle>
46 <manvolnum>8</manvolnum>
50 <refname>runlevel
</refname>
51 <refpurpose>Print previous and current SysV runlevel
</refpurpose>
56 <command>runlevel
</command>
57 <arg choice=
"opt" rep=
"repeat">options
</arg>
62 <title>Overview
</title>
64 <para>"Runlevels" are an obsolete way to start and stop groups of
65 services used in SysV init. systemd provides a compatibility layer
66 that maps runlevels to targets, and associated binaries like
67 <command>runlevel
</command>. Nevertheless, only one runlevel can
68 be
"active" at a given time, while systemd can activate multiple
69 targets concurrently, so the mapping to runlevels is confusing
70 and only approximate. Runlevels should not be used in new code,
71 and are mostly useful as a shorthand way to refer the matching
72 systemd targets in kernel boot parameters.
</para>
75 <title>Mapping between runlevels and systemd targets
</title>
76 <tgroup cols='
2' align='left' colsep='
1' rowsep='
1'
>
77 <colspec colname=
"runlevel" />
78 <colspec colname=
"target" />
81 <entry>Runlevel
</entry>
88 <entry><filename>poweroff.target
</filename></entry>
92 <entry><filename>rescue.target
</filename></entry>
95 <entry>2,
3,
4</entry>
96 <entry><filename>multi-user.target
</filename></entry>
100 <entry><filename>graphical.target
</filename></entry>
104 <entry><filename>reboot.target
</filename></entry>
112 <title>Description
</title>
114 <para><command>runlevel
</command> prints the previous and current
115 SysV runlevel if they are known.
</para>
117 <para>The two runlevel characters are separated by a single space
118 character. If a runlevel cannot be determined, N is printed
119 instead. If neither can be determined, the word
"unknown" is
122 <para>Unless overridden in the environment, this will check the
123 utmp database for recent runlevel changes.
</para>
127 <title>Options
</title>
129 <para>The following option is understood:
</para>
133 <term><option>--help
</option></term>
135 <xi:include href=
"standard-options.xml" xpointer=
"help-text" />
142 <title>Exit status
</title>
144 <para>If one or both runlevels could be determined,
0 is returned,
145 a non-zero failure code otherwise.
</para>
150 <title>Environment
</title>
152 <variablelist class='environment-variables'
>
154 <term><varname>$RUNLEVEL
</varname></term>
156 <listitem><para>If
<varname>$RUNLEVEL
</varname> is set,
157 <command>runlevel
</command> will print this value as current
158 runlevel and ignore utmp.
</para></listitem>
162 <term><varname>$PREVLEVEL
</varname></term>
164 <listitem><para>If
<varname>$PREVLEVEL
</varname> is set,
165 <command>runlevel
</command> will print this value as previous
166 runlevel and ignore utmp.
</para></listitem>
176 <term><filename>/run/utmp
</filename></term>
178 <listitem><para>The utmp database
<command>runlevel
</command> reads the previous and current runlevel
179 from.
</para></listitem>
185 <title>See Also
</title>
187 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
188 <citerefentry><refentrytitle>systemd.target
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
189 <citerefentry><refentrytitle>systemctl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>