Methods of payment Abuse

How to find out session information in loginctl

06.12.2022, 18:47

We have already covered what loginctl is and its syntax. Now let's look at how to view session information. This task is accomplished with one simple command. You can easily view all active sessions and see the information in the GUI.

Finding out information about sessions

To find out information about sessions, you just need to run one simple command - list-sessions:

$ loginctl list-sessions

It allows you to familiarize yourself with all active sessions at a given time. As we can see from the screenshot above, there are two active sessions. The first one is responsible for automatically logging into the GUI when Gnome is running, the second session is the console session in TTY3. We can see that in the GUI we can only see the session ID, as well as the username and TTY.

How can we find out more detailed information about each session? For this purpose, use the session-status command

The session in the GUI looks as follows:

$ loginctl session-status 1

In this case we can see the moment when the session was started, its type, in the screenshot it is X11. A console session in TTY looks like this:

$ loginctl session-status 3

Need to see session settings without process information? Just run show-session:

$ loginctl show-session 1

Using this command, you have the option to specify what kind of information you want to get with the -por --property option.

To get just the type use this command:

$ loginctl show-session 1 --p Type

To get just the value, without the property name, use the --value option:

$ loginctl show-session 1 --p Type --value

We have seen how to view session information in loginctl - there is nothing complicated about it.