Score:1

unable to kill user-session with loginctl

gh flag

I'm running lubuntu 20.04 with sddm as display-manager.

Whenever I logout over gui and login as a different user the user-session is not be killed (do not know if it is by-design). So loginctl shows me doupple sessions for my users.

All sessions from my 2. user I killed with

killall -u second_user_name

for my main user 3 sessions remains.

The session with the lowerst session id i could remove with

sudo loginctl kill-session 3

Leftover

loginctl list-sessions 
SESSION  UID USER SEAT  TTY
     11 1000 alex seat0    
     21 1000 alex seat0    

Next try

alex@Guilmon:~$ sudo loginctl kill-session 11
[sudo] Passwort für alex: 
alex@Guilmon:~$ loginctl list-sessions 
SESSION  UID USER SEAT  TTY
     11 1000 alex seat0    
     21 1000 alex seat0    

2 sessions listed.
alex@Guilmon:~$ 


How can I get rid of it? Or avoid this situation (more than one session per user)
guiverc avatar
cn flag
I'm unsure what you meant with "*logout over gui*", but I created a new user 'blah' on a QA-test system (*impish* as that's the last thing we were QA-testing & thus what I currently have handy) and could not re-create this issue on *impish* (21.10). I may not get to try it today on *focal*...
guiverc avatar
cn flag
Okay, I do see it using a *focal* live system... I don't have time to explore further currently sorry
Score:1
gh flag

I think I found out to avoid this situation. In

/etc/systemd/logind.conf

KillUserProcesses=yes

From manpage

KillUserProcesses=
           Takes a boolean argument. Configures whether the processes of a user should be killed when the user logs out. If true, the scope unit
           corresponding to the session and all processes inside that scope will be terminated. If false, the scope is "abandoned", see
           systemd.scope(5), and processes are not killed. Defaults to "no", but see the options KillOnlyUsers= and KillExcludeUsers= below.

           In addition to session processes, user process may run under the user manager unit user@.service. Depending on the linger settings, this may
           allow users to run processes independent of their login sessions. See the description of enable-linger in loginctl(1).

           Note that setting KillUserProcesses=yes will break tools like screen(1) and tmux(1), unless they are moved out of the session scope. See
           example in systemd-run(1).
I restart 
    sudo systemctl restart systemd-logind.service 

after logout 1. user and logged in to 2. user and back

alex@Guilmon:~$ loginctl 
SESSION  UID USER SEAT  TTY
     15 1000 alex seat0    

1 sessions listed.
alex@Guilmon:~$ 

No longer waiting for stopping something from abandoned user session during shutdown or restart.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.