Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
Wat het doet
Every login (console, SSH, desktop) is a session. loginctl lists sessions and users, shows their processes, locks or ends them, and controls linger: with linger on, systemd starts the user's own service manager at boot and keeps it running after logout. Rootless Podman containers and user timers need linger to run when the user is not logged in.
Zo schrijf je het
loginctl [OPTION]... COMMAND [NAME]...Belangrijkste delen
Sessions
list-sessions- List the current sessions.
session-status[ID]...- Status and processes of a session.
show-session[ID]...- Properties of a session (for scripts).
activate[ID]- Bring a session to the front.
lock-session/unlock-session[ID]...- Lock or unlock the screen of a session.
lock-sessions/unlock-sessions- Lock or unlock all sessions.
terminate-sessionID...- End a session (all its processes).
kill-sessionID...- Send a signal to the processes of a session.
Users
list-users- List logged-in users (and users with linger).
user-status[USER]...- Status and processes of a user.
show-user[USER]...- Properties of a user (
Linger=,State=). enable-linger[USER]...- Keep the user's service manager running without a login.
disable-linger[USER]...- Turn linger off.
terminate-userUSER...- End all sessions of a user.
kill-userUSER...- Send a signal to all processes of a user.
Seats
list-seats/seat-status/show-seat- Seats (a screen, keyboard and mouse set).
attachNAMEDEVICE...- Give a device to a seat.
flush-devices- Remove all device-to-seat assignments.
terminate-seatNAME...- End all sessions on a seat.
Opties 13
Meest gebruikt
Options
Niets past bij dit filter.
Voorbeelden 10
$ als gewone gebruiker# als root (of met sudo)
1Who is logged in?
loginctl list-sessions SESSION UID USER SEAT TTY STATE IDLE SINCE 3 1000 student seat0 tty2 active no - 12 1001 anna - pts/1 active no - loginctl list-users2Look at one session and its processes
loginctl session-status 123End the session of a user
loginctl terminate-session 12 loginctl terminate-user annaEnds all logins and processes of anna. Tell the user first.
4Let a user's containers and timers run without a login
loginctl enable-linger student loginctl show-user student -p Linger --value yes ls /var/lib/systemd/linger/ student5Turn linger off again
loginctl disable-linger student6Lock all screens (for example before a desktop maintenance)
loginctl lock-sessions7Kill only the processes of a user with a signal
loginctl kill-user omar --signal=SIGKILL8Use a property in a script
loginctl show-session $XDG_SESSION_ID -p Type --value wayland9Check if a user's service manager runs
10Show the idle time of every session
Niets past bij dit filter.
Let op
- Without linger, user services (Quadlet containers, user timers) stop at logout and do not start at boot.
terminate-userends all processes of the user, also running jobs.
Bestanden
/var/lib/systemd/linger/- One file per user with linger on.
/etc/systemd/logind.conf, /etc/systemd/logind.conf.d/- Settings of systemd-logind (idle actions, KillUserProcesses).
Tips om te onthouden
loginctl enable-lingerwithout a name works for your own user if polkit allows it.
Exitcodes
0 | Success. |
Not 0 | Error. |