2014-08-24 17:18:18 +00:00
|
|
|
|
<chapter xmlns="http://docbook.org/ns/docbook"
|
|
|
|
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
|
|
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
|
|
|
|
version="5.0"
|
|
|
|
|
xml:id="sec-user-sessions">
|
2018-05-01 23:57:09 +00:00
|
|
|
|
<title>User Sessions</title>
|
|
|
|
|
<para>
|
2019-09-19 17:17:30 +00:00
|
|
|
|
Systemd keeps track of all users who are logged into the system (e.g. on a
|
|
|
|
|
virtual console or remotely via SSH). The command <command>loginctl</command>
|
|
|
|
|
allows querying and manipulating user sessions. For instance, to list all
|
|
|
|
|
user sessions:
|
2014-08-24 17:18:18 +00:00
|
|
|
|
<screen>
|
2019-06-17 11:25:50 +00:00
|
|
|
|
<prompt>$ </prompt>loginctl
|
2014-08-24 17:18:18 +00:00
|
|
|
|
SESSION UID USER SEAT
|
|
|
|
|
c1 500 eelco seat0
|
|
|
|
|
c3 0 root seat0
|
|
|
|
|
c4 500 alice
|
|
|
|
|
</screen>
|
2019-09-19 17:17:30 +00:00
|
|
|
|
This shows that two users are logged in locally, while another is logged in
|
|
|
|
|
remotely. (“Seats” are essentially the combinations of displays and input
|
|
|
|
|
devices attached to the system; usually, there is only one seat.) To get
|
|
|
|
|
information about a session:
|
2014-08-24 17:18:18 +00:00
|
|
|
|
<screen>
|
2019-06-17 11:25:50 +00:00
|
|
|
|
<prompt>$ </prompt>loginctl session-status c3
|
2014-08-24 17:18:18 +00:00
|
|
|
|
c3 - root (0)
|
|
|
|
|
Since: Tue, 2013-01-08 01:17:56 CET; 4min 42s ago
|
|
|
|
|
Leader: 2536 (login)
|
|
|
|
|
Seat: seat0; vc3
|
|
|
|
|
TTY: /dev/tty3
|
|
|
|
|
Service: login; type tty; class user
|
|
|
|
|
State: online
|
|
|
|
|
CGroup: name=systemd:/user/root/c3
|
|
|
|
|
├─ 2536 /nix/store/10mn4xip9n7y9bxqwnsx7xwx2v2g34xn-shadow-4.1.5.1/bin/login --
|
|
|
|
|
├─10339 -bash
|
|
|
|
|
└─10355 w3m nixos.org
|
|
|
|
|
</screen>
|
2019-09-19 17:17:30 +00:00
|
|
|
|
This shows that the user is logged in on virtual console 3. It also lists the
|
|
|
|
|
processes belonging to this session. Since systemd keeps track of this, you
|
|
|
|
|
can terminate a session in a way that ensures that all the session’s
|
|
|
|
|
processes are gone:
|
2014-08-24 17:18:18 +00:00
|
|
|
|
<screen>
|
2020-09-22 22:38:47 +00:00
|
|
|
|
<prompt># </prompt>loginctl terminate-session c3
|
2014-08-24 17:18:18 +00:00
|
|
|
|
</screen>
|
2018-05-01 23:57:09 +00:00
|
|
|
|
</para>
|
2016-06-01 14:23:32 +00:00
|
|
|
|
</chapter>
|