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 Copyright 2010 Lennart Poettering
11 <refentry id=
"runlevel"
12 xmlns:
xi=
"http://www.w3.org/2001/XInclude"
13 conditional=
"ENABLE_UTMP">
16 <title>runlevel
</title>
17 <productname>systemd
</productname>
21 <contrib>Developer
</contrib>
22 <firstname>Lennart
</firstname>
23 <surname>Poettering
</surname>
24 <email>lennart@poettering.net
</email>
30 <refentrytitle>runlevel
</refentrytitle>
31 <manvolnum>8</manvolnum>
35 <refname>runlevel
</refname>
36 <refpurpose>Print previous and current SysV runlevel
</refpurpose>
41 <command>runlevel
</command>
42 <arg choice=
"opt" rep=
"repeat">options
</arg>
47 <title>Overview
</title>
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>
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" />
66 <entry>Runlevel
</entry>
73 <entry><filename>poweroff.target
</filename></entry>
77 <entry><filename>rescue.target
</filename></entry>
80 <entry>2,
3,
4</entry>
81 <entry><filename>multi-user.target
</filename></entry>
85 <entry><filename>graphical.target
</filename></entry>
89 <entry><filename>reboot.target
</filename></entry>
97 <title>Description
</title>
99 <para><command>runlevel
</command> prints the previous and current
100 SysV runlevel if they are known.
</para>
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
107 <para>Unless overridden in the environment, this will check the
108 utmp database for recent runlevel changes.
</para>
112 <title>Options
</title>
114 <para>The following option is understood:
</para>
118 <term><option>--help
</option></term>
120 <xi:include href=
"standard-options.xml" xpointer=
"help-text" />
127 <title>Exit status
</title>
129 <para>If one or both runlevels could be determined,
0 is returned,
130 a non-zero failure code otherwise.
</para>
135 <title>Environment
</title>
137 <variablelist class='environment-variables'
>
139 <term><varname>$RUNLEVEL
</varname></term>
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>
147 <term><varname>$PREVLEVEL
</varname></term>
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>
161 <term><filename>/run/utmp
</filename></term>
163 <listitem><para>The utmp database
<command>runlevel
</command> reads the previous and current runlevel
164 from.
</para></listitem>
170 <title>See Also
</title>
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>