How can I delete a user in linux when the system says its currently used in a process

后端 未结 5 1849
逝去的感伤
逝去的感伤 2021-01-31 14:28

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

However when I use the following command:

userdel -r cafe_fixer

I get the following m

相关标签:
5条回答
  • 2021-01-31 14:49

    It worked i used userdell --force USERNAME Some times eventhough -f and --force is same -f is not working sometimes After i removed the account i exit back to that removed username which i removed from root then what happened is this

    image description here

    0 讨论(0)
  • 2021-01-31 14:52

    Only solution that worked for me

    $ sudo killall -u username && sudo deluser --remove-home -f username
    

    The killall command is used if multiple processes are used by the user you want to delete.

    The -f option forces the removal of the user account, even if the user is still logged in. It also forces deluser to remove the user's home directory and mail spool, even if another user uses the same home directory.

    Please confirm that it works in the comments.

    0 讨论(0)
  • 2021-01-31 15:00
    pkill  <process id>
    userdel <username>
    
    0 讨论(0)
  • 2021-01-31 15:02

    restart your computer and run $sudo deluser username... worked for me

    0 讨论(0)
  • 2021-01-31 15:11

    First use pkill or kill -9 <pid> to kill the process.

    Then use following userdel command to delete user,

    userdel -f cafe_fixer
    

    According to userdel man page:

    -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.

    Edit 1: (by @Ajedi32)

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

    Edit 2: (by @socketpair)

    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.

    0 讨论(0)
提交回复
热议问题