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