1<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-user-sessions">
2 <title>User Sessions</title>
3 <para>
4 Systemd keeps track of all users who are logged into the system
5 (e.g. on a virtual console or remotely via SSH). The command
6 <literal>loginctl</literal> allows querying and manipulating user
7 sessions. For instance, to list all user sessions:
8 </para>
9 <programlisting>
10$ loginctl
11 SESSION UID USER SEAT
12 c1 500 eelco seat0
13 c3 0 root seat0
14 c4 500 alice
15</programlisting>
16 <para>
17 This shows that two users are logged in locally, while another is
18 logged in remotely. (<quote>Seats</quote> are essentially the
19 combinations of displays and input devices attached to the system;
20 usually, there is only one seat.) To get information about a
21 session:
22 </para>
23 <programlisting>
24$ loginctl session-status c3
25c3 - root (0)
26 Since: Tue, 2013-01-08 01:17:56 CET; 4min 42s ago
27 Leader: 2536 (login)
28 Seat: seat0; vc3
29 TTY: /dev/tty3
30 Service: login; type tty; class user
31 State: online
32 CGroup: name=systemd:/user/root/c3
33 ├─ 2536 /nix/store/10mn4xip9n7y9bxqwnsx7xwx2v2g34xn-shadow-4.1.5.1/bin/login --
34 ├─10339 -bash
35 └─10355 w3m nixos.org
36</programlisting>
37 <para>
38 This shows that the user is logged in on virtual console 3. It also
39 lists the processes belonging to this session. Since systemd keeps
40 track of this, you can terminate a session in a way that ensures
41 that all the session’s processes are gone:
42 </para>
43 <programlisting>
44# loginctl terminate-session c3
45</programlisting>
46</chapter>