Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

linux

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 message:

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.

Any help appreciated.

like image 780
chell Avatar asked Jan 23 '15 04:01

chell


People also ask

Which Linux command is used to delete a referenced user account from the system?

userdel command in Linux system is used to delete a user account and related files. This command basically modifies the system account files, deleting all the entries which refer to the username LOGIN.

Is currently used by process Linux?

Sometimes, while using any Linux distribution, most of the users got the Error: “user is currently used by process”. This error could have occurred while changing the username or deleting a user. One of the reasons behind this error is that the user has been deleting or changing a user's name while logging in.


Video Answer


1 Answers

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:

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

Edit 2:

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.

like image 184
Skynet Avatar answered Sep 28 '22 02:09

Skynet