Methods of payment Abuse

Loginctl: basics and syntax

03.12.2022, 02:02

The loginctl program is part of the systemd set of utilities that allow you to manage your system. It gives you the right to manage current user sessions, view the list of active users, lock the screen or interrupt sessions altogether, and terminate user processes. Not so long ago, for this purpose, users used several programs and configuration files. But now everything is in one place.

The basics of loginctl

The loginctl program gives the user the right to manage everything that has to do with user authorization. The documentation says that the program is designed to manage the systemd-logind login manager.

The utility manages:

  • user (user) - a user who has been registered in the system;
  • session- user logging in to the system, each login, except sudo and su, is treated as a new session. It is possible to authorize multiple TTYs, via SSH. Logging into the graphical manager will also be treated as a new session;
  • seat- a concept that allows multiple monitors or peripherals to be connected to a PC and used by different users at the same time. But, as a rule, this is not used, and the program displays only one workplace.

Let's look at the syntax and available options of loginctl.

Syntax of loginctl

The syntax of the program is simple and straightforward:

$ loginctl [options] command [arguments]

Here are the commands available for use:

list-sessions - outputs a listof sessions.

session-status - displays session status, authorization date, and information about the main services and processes running.

show-session - displays session settings.

activate - allows switching to the specified session.

lock-session - locks the screen for the specified session; if no session ID is specified, locks the screen for the current session.

unlock-session - unlocks the screen for the specified session.

kill-session - allows to terminate the session or send a specific signal to all processes.

terminate-session - terminates the specified session.

list-users - displays the list of users who are currently authorized.

user-status - similar to session-status, displays authorization date, status and all running processes in a tree view.

show-user - displays information about the user and his current session without running processes.

terminate-user -terminates all user sessions and all user processes.

kill-user - sends a signal to all user's processes, by default SIGTERM is sent.

list-seats - displays the list of workstations.

seat-status - displays all processes running within the specified workplace.

show-seat - displays the workplace settings.

terminate-seat -terminates all processes of the workplace.

Workplace settings will not be discussed within the scope of this material. There is no sense in citing the commands. Please note that many commands can function properly only in case of graphical interface, in particular session-lock or session-unlock is not supported for TTY or SSH sessions. In the next article we will look at real examples.