首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用loginctl杀死用户会话。

无法使用loginctl杀死用户会话。
EN

Ask Ubuntu用户
提问于 2021-10-17 11:01:48
回答 1查看 1.5K关注 0票数 1

我正在运行lubuntu 20.04,sddm作为显示管理器。

每当我退出gui并以不同的用户身份登录时,用户会话就不会被终止(不知道它是否是由设计完成的)。所以loginctl为我的用户展示了双倍会话。

与我一起杀死的2用户的所有会话

代码语言:javascript
复制
killall -u second_user_name

对于我的主要用户来说,仍然有3个会话。

具有最低会话id的会话,我可以用它删除。

代码语言:javascript
复制
sudo loginctl kill-session 3

剩菜

代码语言:javascript
复制
loginctl list-sessions 
SESSION  UID USER SEAT  TTY
     11 1000 alex seat0    
     21 1000 alex seat0    

下一次尝试

代码语言:javascript
复制
alex@Guilmon:~$ sudo loginctl kill-session 11
[sudo] Passwort für alex: 
代码语言:javascript
复制
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)
EN

回答 1

Ask Ubuntu用户

回答已采纳

发布于 2021-10-18 12:27:23

我想我找到了避免这种情况的办法。在……里面

代码语言:javascript
复制
/etc/systemd/logind.conf

KillUserProcesses=yes

从手册中

代码语言:javascript
复制
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).
代码语言:javascript
复制
I restart 
代码语言:javascript
复制
    sudo systemctl restart systemd-logind.service 

退出后,1. user并登录到2. user和back

代码语言:javascript
复制
alex@Guilmon:~$ loginctl 
SESSION  UID USER SEAT  TTY
     15 1000 alex seat0    

1 sessions listed.
alex@Guilmon:~$ 

在关闭或重新启动期间,不再等待从放弃的用户会话中停止某些内容。

票数 2
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1369771

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档