1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
6 <refentry id="loginctl" conditional='ENABLE_LOGIND'
7 xmlns:xi="http://www.w3.org/2001/XInclude">
10 <title>loginctl</title>
11 <productname>systemd</productname>
15 <refentrytitle>loginctl</refentrytitle>
16 <manvolnum>1</manvolnum>
20 <refname>loginctl</refname>
21 <refpurpose>Control the systemd login manager</refpurpose>
26 <command>loginctl</command>
27 <arg choice="opt" rep="repeat">OPTIONS</arg>
28 <arg choice="req">COMMAND</arg>
29 <arg choice="opt" rep="repeat">NAME</arg>
34 <title>Description</title>
36 <para><command>loginctl</command> may be used to introspect and
37 control the state of the
38 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
40 <citerefentry><refentrytitle>systemd-logind.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
44 <title>Commands</title>
46 <para>The following commands are understood:</para>
48 <refsect2><title>Session Commands</title><variablelist>
51 <term><command>list-sessions</command></term>
53 <listitem><para>List current sessions.</para></listitem>
57 <term><command>session-status</command> <optional><replaceable>ID</replaceable>…</optional></term>
59 <listitem><para>Show terse runtime status information about
60 one or more sessions, followed by the most recent log data
61 from the journal. Takes one or more session identifiers as
62 parameters. If no session identifiers are passed, the status of
63 the caller's session is shown. This function is intended to
64 generate human-readable output. If you are looking for
65 computer-parsable output, use <command>show-session</command>
68 <xi:include href="version-info.xml" xpointer="v233"/></listitem>
72 <term><command>show-session</command> <optional><replaceable>ID</replaceable>…</optional></term>
74 <listitem><para>Show properties of one or more sessions or the manager itself. If no argument is
75 specified, properties of the manager will be shown. If a session ID is specified, properties of
76 the session are shown. Specially, if the given ID is <literal>self</literal>, the session to which
77 the <command>loginctl</command> process belongs is used. If <literal>auto</literal>, the current
78 session is used as with <literal>self</literal> if exists, and falls back to the current user's
79 graphical session. By default, empty properties are suppressed. Use <option>--all</option> to show
80 those too. To select specific properties to show, use <option>--property=</option>. This command
81 is intended to be used whenever computer-parsable output is required. Use <command>session-status</command>
82 if you are looking for formatted human-readable output.</para>
84 <xi:include href="version-info.xml" xpointer="v233"/></listitem>
88 <term><command>activate</command> <optional><replaceable>ID</replaceable></optional></term>
90 <listitem><para>Activate a session. This brings a session into
91 the foreground if another session is currently in the
92 foreground on the respective seat. Takes a session identifier
93 as argument. If no argument is specified, the session of the
94 caller is put into foreground.</para>
96 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
100 <term><command>lock-session</command> <optional><replaceable>ID</replaceable>…</optional></term>
101 <term><command>unlock-session</command> <optional><replaceable>ID</replaceable>…</optional></term>
103 <listitem><para>Activates/deactivates the screen lock on one
104 or more sessions, if the session supports it. Takes one or
105 more session identifiers as arguments. If no argument is
106 specified, the session of the caller is locked/unlocked.
109 <xi:include href="version-info.xml" xpointer="v233"/></listitem>
113 <term><command>lock-sessions</command></term>
114 <term><command>unlock-sessions</command></term>
116 <listitem><para>Activates/deactivates the screen lock on all
117 current sessions supporting it. </para>
119 <xi:include href="version-info.xml" xpointer="v188"/></listitem>
123 <term><command>terminate-session</command> <replaceable>ID</replaceable>…</term>
125 <listitem><para>Terminates a session. This kills all processes of the session and deallocates all
126 resources attached to the session. If the argument is specified as empty string the session invoking
127 the command is terminated.</para>
129 <xi:include href="version-info.xml" xpointer="v233"/></listitem>
133 <term><command>kill-session</command> <replaceable>ID</replaceable>…</term>
135 <listitem><para>Send a signal to one or more processes of the session. Use
136 <option>--kill-whom=</option> to select which process to kill. Use <option>--signal=</option> to
137 select the signal to send. If the argument is specified as empty string the signal is sent to the
138 session invoking the command.</para>
140 <xi:include href="version-info.xml" xpointer="v233"/></listitem>
142 </variablelist></refsect2>
144 <refsect2><title>User Commands</title><variablelist>
146 <term><command>list-users</command></term>
148 <listitem><para>List currently logged in users.
153 <term><command>user-status</command> <optional><replaceable>USER</replaceable>…</optional></term>
155 <listitem><para>Show terse runtime status information about
156 one or more logged in users, followed by the most recent log
157 data from the journal. Takes one or more user names or numeric
158 user IDs as parameters. If no parameters are passed, the status
159 is shown for the user of the session of the caller. This
160 function is intended to generate human-readable output. If you
161 are looking for computer-parsable output, use
162 <command>show-user</command> instead.</para>
164 <xi:include href="version-info.xml" xpointer="v233"/></listitem>
168 <term><command>show-user</command> <optional><replaceable>USER</replaceable>…</optional></term>
170 <listitem><para>Show properties of one or more users or the
171 manager itself. If no argument is specified, properties of the
172 manager will be shown. If a user is specified, properties of
173 the user are shown. By default, empty properties are
174 suppressed. Use <option>--all</option> to show those too. To
175 select specific properties to show, use
176 <option>--property=</option>. This command is intended to be
177 used whenever computer-parsable output is required. Use
178 <command>user-status</command> if you are looking for
179 formatted human-readable output.</para>
181 <xi:include href="version-info.xml" xpointer="v233"/></listitem>
185 <term><command>enable-linger</command> <optional><replaceable>USER</replaceable>…</optional></term>
186 <term><command>disable-linger</command> <optional><replaceable>USER</replaceable>…</optional></term>
188 <listitem><para>Enable/disable user lingering for one or more
189 users. If enabled for a specific user, a user manager is
190 spawned for the user at boot and kept around after logouts.
191 This allows users who are not logged in to run long-running
192 services. Takes one or more user names or numeric UIDs as
193 argument. If no argument is specified, enables/disables
194 lingering for the user of the session of the caller.</para>
196 <para>See also <varname>KillUserProcesses=</varname> setting in
197 <citerefentry><refentrytitle>logind.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
200 <xi:include href="version-info.xml" xpointer="v233"/></listitem>
204 <term><command>terminate-user</command> <replaceable>USER</replaceable>…</term>
206 <listitem><para>Terminates all sessions of a user. This kills all processes of all sessions of the
207 user and deallocates all runtime resources attached to the user. If the argument is specified as
208 empty string the sessions of the user invoking the command are terminated.</para>
210 <xi:include href="version-info.xml" xpointer="v233"/></listitem>
214 <term><command>kill-user</command> <replaceable>USER</replaceable>…</term>
216 <listitem><para>Send a signal to all processes of a user. Use <option>--signal=</option> to select
217 the signal to send. If the argument is specified as empty string the signal is sent to the sessions
218 of the user invoking the command.</para>
220 <xi:include href="version-info.xml" xpointer="v233"/></listitem>
222 </variablelist></refsect2>
224 <refsect2><title>Seat Commands</title><variablelist>
226 <term><command>list-seats</command></term>
228 <listitem><para>List currently available seats on the local
229 system.</para></listitem>
233 <term><command>seat-status</command> <optional><replaceable>NAME</replaceable>…</optional></term>
235 <listitem><para>Show terse runtime status information about
236 one or more seats. Takes one or more seat names as parameters.
237 If no seat names are passed the status of the caller's
238 session's seat is shown. This function is intended to generate
239 human-readable output. If you are looking for
240 computer-parsable output, use <command>show-seat</command>
243 <xi:include href="version-info.xml" xpointer="v233"/></listitem>
247 <term><command>show-seat</command> <optional><replaceable>NAME</replaceable>…</optional></term>
249 <listitem><para>Show properties of one or more seats or the
250 manager itself. If no argument is specified, properties of the
251 manager will be shown. If a seat is specified, properties of
252 the seat are shown. By default, empty properties are
253 suppressed. Use <option>--all</option> to show those too. To
254 select specific properties to show, use
255 <option>--property=</option>. This command is intended to be
256 used whenever computer-parsable output is required. Use
257 <command>seat-status</command> if you are looking for
258 formatted human-readable output.</para>
260 <xi:include href="version-info.xml" xpointer="v233"/></listitem>
264 <term><command>attach</command> <replaceable>NAME</replaceable> <replaceable>DEVICE</replaceable>…</term>
266 <listitem><para>Persistently attach one or more devices to a
267 seat. The devices should be specified via device paths in the
268 <filename>/sys/</filename> file system. To create a new seat,
269 attach at least one graphics card to a previously unused seat
270 name. Seat names may consist only of a–z, A–Z, 0–9,
271 <literal>-</literal> and <literal>_</literal> and must be
272 prefixed with <literal>seat</literal>. To drop assignment of a
273 device to a specific seat, just reassign it to a different
274 seat, or use <command>flush-devices</command>.
277 <xi:include href="version-info.xml" xpointer="v233"/></listitem>
281 <term><command>flush-devices</command></term>
283 <listitem><para>Removes all device assignments previously
284 created with <command>attach</command>. After this call, only
285 automatically generated seats will remain, and all seat
286 hardware is assigned to them.</para></listitem>
290 <term><command>terminate-seat</command> <replaceable>NAME</replaceable>…</term>
292 <listitem><para>Terminates all sessions on a seat. This kills
293 all processes of all sessions on the seat and deallocates all
294 runtime resources attached to them.</para>
296 <xi:include href="version-info.xml" xpointer="v233"/></listitem>
298 </variablelist></refsect2>
303 <title>Options</title>
305 <para>The following options are understood:</para>
309 <term><option>--no-ask-password</option></term>
311 <listitem><para>Do not query the user for authentication for
312 privileged operations.</para></listitem>
316 <term><option>-p</option></term>
317 <term><option>--property=</option></term>
319 <listitem><para>When showing session/user/seat properties,
320 limit display to certain properties as specified as argument.
321 If not specified, all set properties are shown. The argument
322 should be a property name, such as
323 <literal>Sessions</literal>. If specified more than once, all
324 properties with the specified names are
325 shown.</para></listitem>
329 <term><option>--value</option></term>
331 <listitem><para>When showing session/user/seat properties,
332 only print the value, and skip the property name and
333 <literal>=</literal>.</para>
335 <xi:include href="version-info.xml" xpointer="v230"/></listitem>
339 <term><option>-a</option></term>
340 <term><option>--all</option></term>
342 <listitem><para>When showing session/user/seat properties,
343 show all properties regardless of whether they are set or
344 not.</para></listitem>
348 <term><option>-l</option></term>
349 <term><option>--full</option></term>
351 <listitem><para>Do not ellipsize process tree entries.</para>
353 <xi:include href="version-info.xml" xpointer="v198"/>
358 <term><option>--kill-whom=</option></term>
360 <listitem><para>When used with <command>kill-session</command>, choose which processes to kill.
361 Takes one of <literal>leader</literal> or <literal>all</literal>, to select whether to kill only
362 the leader process of the session or all processes of the session. If omitted, defaults to
363 <option>all</option>.</para>
365 <xi:include href="version-info.xml" xpointer="v252"/></listitem>
369 <term><option>-s</option></term>
370 <term><option>--signal=</option></term>
372 <listitem><para>When used with <command>kill-session</command> or <command>kill-user</command>,
373 choose which signal to send to selected processes. Must be one of the well known signal specifiers,
374 such as <constant>SIGTERM</constant>, <constant>SIGINT</constant> or <constant>SIGSTOP</constant>.
375 If omitted, defaults to <constant>SIGTERM</constant>.</para>
377 <para>The special value <literal>help</literal> will list the known values and the program will exit
378 immediately, and the special value <literal>list</literal> will list known values along with the
379 numerical signal numbers and the program will exit immediately.</para></listitem>
383 <term><option>-n</option></term>
384 <term><option>--lines=</option></term>
386 <listitem><para>When used with <command>user-status</command>
387 and <command>session-status</command>, controls the number of
388 journal lines to show, counting from the most recent ones.
389 Takes a positive integer argument. Defaults to 10.</para>
391 <xi:include href="version-info.xml" xpointer="v219"/>
396 <term><option>-o</option></term>
397 <term><option>--output=</option></term>
399 <listitem><para>When used with <command>user-status</command>
400 and <command>session-status</command>, controls the formatting
401 of the journal entries that are shown. For the available
403 <citerefentry><refentrytitle>journalctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
404 Defaults to <literal>short</literal>.</para>
406 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
409 <xi:include href="user-system-options.xml" xpointer="host" />
410 <xi:include href="user-system-options.xml" xpointer="machine" />
412 <xi:include href="standard-options.xml" xpointer="no-pager" />
413 <xi:include href="standard-options.xml" xpointer="no-legend" />
414 <xi:include href="standard-options.xml" xpointer="help" />
415 <xi:include href="standard-options.xml" xpointer="version" />
420 <title>Exit status</title>
422 <para>On success, 0 is returned, a non-zero failure code
427 <title>Examples</title>
430 <title>Querying user status</title>
432 <programlisting>$ loginctl user-status
434 Since: Sat 2016-04-09 14:23:31 EDT; 54min ago
437 Unit: user-1005.slice
443 ├─3473 login -- fatima
446 Apr 09 14:40:30 laptop login[2325]: pam_unix(login:session):
447 session opened for user fatima by LOGIN(uid=0)
448 Apr 09 14:40:30 laptop login[2325]: LOGIN ON tty3 BY fatima
451 <para>There are two sessions, 3 and 5. Session 3 is a graphical session,
452 marked with a star. The tree of processing including the two corresponding
453 scope units and the user manager unit are shown.</para>
457 <xi:include href="common-variables.xml" />
460 <title>See Also</title>
462 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
463 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
464 <citerefentry><refentrytitle>systemd-logind.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
465 <citerefentry><refentrytitle>logind.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>