系统显示当前在进程中使用的用户时,如何删除Linux中的用户 [英] How can I delete a user in linux when the system says its currently used in a process

查看:790
本文介绍了系统显示当前在进程中使用的用户时,如何删除Linux中的用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试删除我在ubuntu上创建的用户.

I am trying to delete a user I created on ubuntu.

但是,当我使用以下命令时:

However when I use the following command:

userdel -r cafe_fixer

我收到以下消息:

user cafe_fixer is currently used by process 15945

我不使用该用户执行我刚刚创建的任何操作,现在希望将其删除.

I am not using this user for anything I just created it and now wish to delete it.

任何帮助表示赞赏.

推荐答案

首先使用pkillkill -9 <pid>终止进程.

然后使用以下userdel命令删除用户,

Then use following userdel command to delete user,

userdel -f cafe_fixer

根据userdel手册页:

-f,--force

-f, --force

此选项将强制删除用户帐户,即使该用户 仍处于登录状态.这也会强制userdel删除用户的住所 目录和邮件假脱机,即使另一个用户使用相同的主目录 目录,或者邮件假脱机不属于指定用户.如果 如果在/etc/login.defs中将USERGROUPS_ENAB定义为yes 存在与已删除用户同名的用户,则该组将是 已删除,即使它仍然是另一个用户的主要组.

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 :(由@ Ajedi32创建)

Edit 1: (by @Ajedi32)

注意:此选项(即--force)很危险,可能会使您的系统处于不一致状态.

Note: This option (i.e. --force) is dangerous and may leave your system in an inconsistent state.

编辑2 :(通过@socketpair)

Edit 2: (by @socketpair)

尽管有一些文件的描述,但此键允许删除正在使用的用户.不要忘记之前的chdir /,因为此命令还将删除主目录.

In spite of the description about some files, this key allows removing the user while it is in use. Don't forget to chdir / before, because this command will also remove home directory.

这篇关于系统显示当前在进程中使用的用户时,如何删除Linux中的用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆