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 This file is part of systemd.
8 Copyright 2010 Lennart Poettering
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 <refentry id=
"runlevel"
25 xmlns:
xi=
"http://www.w3.org/2001/XInclude"
26 conditional=
"HAVE_UTMP">
29 <title>runlevel
</title>
30 <productname>systemd
</productname>
34 <contrib>Developer
</contrib>
35 <firstname>Lennart
</firstname>
36 <surname>Poettering
</surname>
37 <email>lennart@poettering.net
</email>
43 <refentrytitle>runlevel
</refentrytitle>
44 <manvolnum>8</manvolnum>
48 <refname>runlevel
</refname>
49 <refpurpose>Print previous and current SysV runlevel
</refpurpose>
54 <command>runlevel
</command>
55 <arg choice=
"opt" rep=
"repeat">options
</arg>
60 <title>Overview
</title>
62 <para>"Runlevels" are an obsolete way to start and stop groups of
63 services used in SysV init. systemd provides a compatibility layer
64 that maps runlevels to targets, and associated binaries like
65 <command>runlevel
</command>. Nevertheless, only one runlevel can
66 be
"active" at a given time, while systemd can activate multiple
67 targets concurrently, so the mapping to runlevels is confusing
68 and only approximate. Runlevels should not be used in new code,
69 and are mostly useful as a shorthand way to refer the matching
70 systemd targets in kernel boot parameters.
</para>
73 <title>Mapping between runlevels and systemd targets
</title>
74 <tgroup cols='
2' align='left' colsep='
1' rowsep='
1'
>
75 <colspec colname=
"runlevel" />
76 <colspec colname=
"target" />
79 <entry>Runlevel
</entry>
86 <entry><filename>poweroff.target
</filename></entry>
90 <entry><filename>rescue.target
</filename></entry>
93 <entry>2,
3,
4</entry>
94 <entry><filename>multi-user.target
</filename></entry>
98 <entry><filename>graphical.target
</filename></entry>
102 <entry><filename>reboot.target
</filename></entry>
110 <title>Description
</title>
112 <para><command>runlevel
</command> prints the previous and current
113 SysV runlevel if they are known.
</para>
115 <para>The two runlevel characters are separated by a single space
116 character. If a runlevel cannot be determined, N is printed
117 instead. If neither can be determined, the word
"unknown" is
120 <para>Unless overridden in the environment, this will check the
121 utmp database for recent runlevel changes.
</para>
125 <title>Options
</title>
127 <para>The following option is understood:
</para>
131 <term><option>--help
</option></term>
133 <xi:include href=
"standard-options.xml" xpointer=
"help-text" />
140 <title>Exit status
</title>
142 <para>If one or both runlevels could be determined,
0 is returned,
143 a non-zero failure code otherwise.
</para>
148 <title>Environment
</title>
150 <variablelist class='environment-variables'
>
152 <term><varname>$RUNLEVEL
</varname></term>
154 <listitem><para>If
<varname>$RUNLEVEL
</varname> is set,
155 <command>runlevel
</command> will print this value as current
156 runlevel and ignore utmp.
</para></listitem>
160 <term><varname>$PREVLEVEL
</varname></term>
162 <listitem><para>If
<varname>$PREVLEVEL
</varname> is set,
163 <command>runlevel
</command> will print this value as previous
164 runlevel and ignore utmp.
</para></listitem>
174 <term><filename>/var/run/utmp
</filename></term>
176 <listitem><para>The utmp database
<command>runlevel
</command>
177 reads the previous and current runlevel
178 from.
</para></listitem>
184 <title>See Also
</title>
186 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
187 <citerefentry><refentrytitle>systemd.target
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
188 <citerefentry><refentrytitle>systemctl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>