Methods of payment Abuse

Switching to another session and terminating processes in loginctl

09.12.2022, 16:30

We have reviewed the syntax and other important features of the loginctl program, now let's talk about how to switch between sessions and terminate processes. It is very simple to do this and you do not need to have specific knowledge. Next, we will tell you how to implement all this in practice.

Changing the session by switching

How do I switch to another session? You can use a GPU for this. But if you don't want to use the terminal, then solve the problem using the utility.

To do this, you just need to do:

$ loginctl activate 3

The command allows you to switch the session with the identifier. You can switch back in the same way. Even more convenience in switching is provided by TTY due to hot keys. After switching, you can immediately lock the screen.

Execute session-lock:

$ loginctl session-lock 1

Next, we will tell you the instructions for completing a certain user process.

End of session and process

We turn to the consideration of the next issue - the completion of active processes and certain sessions. Using kill-user or kill-session, you can terminate processes running on behalf of a user or only a specific session. These two commands work exactly the same as the kill console utility, therefore, they will be able to complete the process, as well as send a certain signal.

When the kill-session just ends it:

$ loginctl kill-session 3

The user can also use the --signal option to send any other signal. It is set so that the SIGTERM signal is always sent.

To perform a SIGKILL transfer, run:

$ loginctl kill-session 3 --signal SIGKILL

There is also a command that allows you to complete all active processes of one user - kill-user. You can also apply session-terminate. It solves an identical problem and also gives the right to select a signal and complete the process at the same hour:

$ loginctl terminate-session 3

Now you know even more about loginctl.