当系统显示其当前在进程中使用时,如何删除 linux 中的用户
How can I delete a user in linux when the system says its currently used in a process
我正在尝试删除我在 ubuntu 上创建的用户。
但是当我使用以下命令时:
userdel -r cafe_fixer
我收到以下消息:
user cafe_fixer is currently used by process 15945
我没有将此用户用于我刚刚创建的任何内容,现在想删除它。
感谢任何帮助。
先用pkill
或kill -9 <pid>
杀进程
然后使用下面的userdel
命令删除用户,
userdel -f cafe_fixer
根据 userdel
手册页:
-f, --force
This option forces the removal of the user account, even if the user
is still logged in. It also forces userdel to remove the user's home
directory and mail spool, even if another user uses the same home
directory or if the mail spool is not owned by the specified user. If
USERGROUPS_ENAB is defined to yes in /etc/login.defs and if a group
exists with the same name as the deleted user, then this group will be
removed, even if it is still the primary group of another user.
编辑 1:
注意:此选项(即 --force
)很危险,可能会使您的系统处于不一致状态。
编辑 2:
尽管对某些文件有描述,但此密钥允许在使用时删除用户。不要忘记之前chdir /
,因为这个命令也会删除主目录。
pkill <process id>
userdel <username>
唯一对我有用的解决方案
$ sudo killall -u username && sudo deluser --remove-home -f username
如果要删除的用户使用了多个进程,则使用killall
命令。
-f
选项强制删除用户帐户,即使用户仍处于登录状态。它还强制 deluser
删除用户的主目录和邮件假脱机,即使另一个用户使用相同的主目录。
请在评论中确认它是否有效。
重启你的电脑,运行 $sudo deluser 用户名...对我有用
我用过
userdell --force 用户名
有时尽管 -f 和 --force 是相同的 -f 有时不起作用
在我删除帐户后,我退出回到我从 root 中删除的那个删除的用户名,然后发生的事情是这样的
我正在尝试删除我在 ubuntu 上创建的用户。
但是当我使用以下命令时:
userdel -r cafe_fixer
我收到以下消息:
user cafe_fixer is currently used by process 15945
我没有将此用户用于我刚刚创建的任何内容,现在想删除它。
感谢任何帮助。
先用pkill
或kill -9 <pid>
杀进程
然后使用下面的userdel
命令删除用户,
userdel -f cafe_fixer
根据 userdel
手册页:
-f, --force
This option forces the removal of the user account, even if the user is still logged in. It also forces userdel to remove the user's home directory and mail spool, even if another user uses the same home directory or if the mail spool is not owned by the specified user. If USERGROUPS_ENAB is defined to yes in /etc/login.defs and if a group exists with the same name as the deleted user, then this group will be removed, even if it is still the primary group of another user.
编辑 1:
注意:此选项(即 --force
)很危险,可能会使您的系统处于不一致状态。
编辑 2:
尽管对某些文件有描述,但此密钥允许在使用时删除用户。不要忘记之前chdir /
,因为这个命令也会删除主目录。
pkill <process id>
userdel <username>
唯一对我有用的解决方案
$ sudo killall -u username && sudo deluser --remove-home -f username
如果要删除的用户使用了多个进程,则使用killall
命令。
-f
选项强制删除用户帐户,即使用户仍处于登录状态。它还强制 deluser
删除用户的主目录和邮件假脱机,即使另一个用户使用相同的主目录。
请在评论中确认它是否有效。
重启你的电脑,运行 $sudo deluser 用户名...对我有用
我用过 userdell --force 用户名 有时尽管 -f 和 --force 是相同的 -f 有时不起作用 在我删除帐户后,我退出回到我从 root 中删除的那个删除的用户名,然后发生的事情是这样的