$linuxjunkies
>

loginctl(1)

Control the systemd login manager to inspect and manage user logins, sessions, and seats.

UbuntuDebianFedoraArch

Synopsis

loginctl [OPTIONS...] {COMMAND} [NAME...]

Description

loginctl is a utility for introspecting and controlling the state of the systemd login manager (logind). It can be used to examine logged-in users and sessions, manage user sessions and seats, and control system power state. The login manager tracks user logins, sessions, and the hardware seats they are attached to.

Most operations require appropriate permissions; regular users can typically query information about their own sessions, while privileged operations like terminating sessions or changing power state require root or appropriate polkit authorization.

Common options

FlagWhat it does
-p, --property=NAMEWhen showing session/user/seat properties, limit output to specified property names
-a, --allShow all properties and sessions, including empty ones
-l, --fullDo not truncate output to fit terminal width
-n, --lines=INTEGERNumber of journal lines to show when displaying session logs
--output=FORMATControl output format; use 'json' or 'json-pretty' for machine-readable output
-H, --host=HOSTExecute operation on remote host (requires SSH access)
-M, --machine=NAMEExecute operation on local container or machine
--no-pagerDo not pipe output into a pager; show all output directly
--no-legendDo not show column headers and footers in output
-q, --quietSuppress normal output; useful for scripting

Examples

List all active user sessions on the system

loginctl list-sessions

Display all users currently logged in

loginctl list-users

Display detailed properties of session number 2

loginctl show-session 2

Show properties and sessions for a specific user

loginctl show-user username

Display status and devices for a hardware seat

loginctl seat-status seat0

Terminate a specific user session immediately

loginctl terminate-session 5

Lock the current session (suspend screensaver/lock screen)

loginctl lock-session

Power off the system (equivalent to shutdown -h now)

loginctl poweroff

Related commands