Methods of payment Abuse

How to find out user information and switch process in loginctl

08.12.2022, 21:12

In past articles, we've talked about what the loginctl utility is, as well as how you can find out information about a process. In this article, let's look at how you can view user information, and if necessary, switch the process.

How to view user information

You already know how to view all the information about sessions, so viewing information about a user is very similar to this. That is, it is done on almost the same principle.

You can view the list of authorized users using the command:

$ loginctl list-users

Using the command user-status you will be able to find out in detail all the information about any user.

At the same time, you will get acquainted with the details of his session:

$ loginctl user-status 1000

Sessions shows all the IDs of all sessions, with the current session marked with a star. Below that you can see Systemd and all services that have been started on behalf of the user, as well as all processes. The list of processes can be abbreviated.

Use the -l or --full option if you wish to see all processes:

$ loginctl user-status 1000 --full

Need utility output information without pagination?

Use --no-pager:

$ loginctl user-status 1000 --no-pager

Switching to another session

It is also possible for every user to switch from one session to another using the GUI (Gnome or KDE). Want to perform a task in the terminal? Use loginctl. To switch to the session with ID 3 apply the command:

$ loginctl activate 3

Afterwards you can switch back. This is more convenient than switching by TTY using hotkeys. After switching, you will lock the screen from the previous session.

Use the session-lock command:

$ loginctl session-lock 1

Now you know more interesting, useful information about the loginctl program and its capabilities that you can use in your practice.