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