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
13 <refentry id=
"runlevel"
14 xmlns:
xi=
"http://www.w3.org/2001/XInclude"
15 conditional=
"ENABLE_UTMP">
18 <title>runlevel
</title>
19 <productname>systemd
</productname>
23 <contrib>Developer
</contrib>
24 <firstname>Lennart
</firstname>
25 <surname>Poettering
</surname>
26 <email>lennart@poettering.net
</email>
32 <refentrytitle>runlevel
</refentrytitle>
33 <manvolnum>8</manvolnum>
37 <refname>runlevel
</refname>
38 <refpurpose>Print previous and current SysV runlevel
</refpurpose>
43 <command>runlevel
</command>
44 <arg choice=
"opt" rep=
"repeat">options
</arg>
49 <title>Overview
</title>
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>
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" />
68 <entry>Runlevel
</entry>
75 <entry><filename>poweroff.target
</filename></entry>
79 <entry><filename>rescue.target
</filename></entry>
82 <entry>2,
3,
4</entry>
83 <entry><filename>multi-user.target
</filename></entry>
87 <entry><filename>graphical.target
</filename></entry>
91 <entry><filename>reboot.target
</filename></entry>
99 <title>Description
</title>
101 <para><command>runlevel
</command> prints the previous and current
102 SysV runlevel if they are known.
</para>
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
109 <para>Unless overridden in the environment, this will check the
110 utmp database for recent runlevel changes.
</para>
114 <title>Options
</title>
116 <para>The following option is understood:
</para>
120 <term><option>--help
</option></term>
122 <xi:include href=
"standard-options.xml" xpointer=
"help-text" />
129 <title>Exit status
</title>
131 <para>If one or both runlevels could be determined,
0 is returned,
132 a non-zero failure code otherwise.
</para>
137 <title>Environment
</title>
139 <variablelist class='environment-variables'
>
141 <term><varname>$RUNLEVEL
</varname></term>
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>
149 <term><varname>$PREVLEVEL
</varname></term>
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>
163 <term><filename>/run/utmp
</filename></term>
165 <listitem><para>The utmp database
<command>runlevel
</command> reads the previous and current runlevel
166 from.
</para></listitem>
172 <title>See Also
</title>
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>