How can I delete a user in linux when the system says its currently used in a process
how to delete multiple users in linux
delete user linux
list users linux
userdel -r username
delete user ubuntu
userdel command not found
userdel vs deluser
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.
kill -9 <pid> to kill the process.
Then use following
userdel command to delete user,
userdel -f cafe_fixer
userdel man page:
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.
userdel: user m is currently used by process 1 # killall -KILL -u m You may have a command on your system named vipw , which lets you safely say: manually edit the password file to change m 's UID to a number not used by Source: http://www.shellhacks.com/en/HowTo-Create-USER-with-ROOT-Privileges-in-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.
Only solution that worked for me
$ sudo killall -u username && sudo deluser --remove-home -f username
killall command is used if multiple processes are used by the user you want to delete.
-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.
This tutorial explains the userdel command and its options. Linux is a multi-user system, which means that more than one person can interact To delete users using the userdel command, you need to be logged in as root or if there are running processes that belong to this user, the userdel command You need to use the userdel command to delete a user account and related files from user account under Linux operating system. The userdel command must be run as root user on Linux. The userdel command must be run as root user on Linux.
pkill <process id> userdel <username>
To quote man usermod : CAVEATS You must make certain that the named user is not executing any processes when this command is being executed if the Example5: Delete user account along with his home directory and his personal files which are located in different locations which you are not aware. deluser –remove-all-files username Example6: Delete user account and take backup of his files to a directory for future use by the company.
restart your computer and run $sudo deluser username... worked for me
If you try to delete a user with UID 0 by userdel command, you will get following error - userdel: user user01 is currently used by process 1. To delete this user If you need to delete non-root user having UID 0 (say user01), follow the steps below. 1. Backup the Note – Never ever try to delete root user or change its UID. As a System Administrator in Linux, you may have to remove users account at after sometime when a user account may become dormant for so long, or user may leave the organization or company or any other reasons. When removing user accounts on a Linux system,
If you just want to delete a user account from your system and aren't concerned RELATED: How to Use the ps Command to Monitor Linux Processes Now that we've prevented the user from logging back in, we can kill his remove the jobs, and the -u (user) option tells crontab whose jobs to remove. To stop the user logging in again, edit the /etc/passwd file and remove the user or change the 7th column to /sbin/nologin. Run: ps -u <user> to see what process the user is still using and kill them all of them. You may have to use: kill -s 9 <pid> to force the process to stop.
Whenever a new employee joins in your organization, we need to create the We generally use the userdel command to remove the user account in Linux. userdel command is used to delete a user account and related files from the Linux system. userdel -rf user3 userdel: user user3 is currently used by process 30371 I'm trying to delete a user: pgrep -u test ps -fp $(pgrep -u test) killall -KILL -u test userdel -r test But the last command always returns . userdel: user test is currently used by process xxx where xxx is always different.
quotas The limits that can be imposed on users and groups for filesystem usage. to itself and its own contents; a recursive search includes all subdirectories in a used to alter the nice value of a process currently running on the system. used to remove a module from the Linux kernel. rogue process A process that has Solution was, first create the new user and add it to desired groups (ie. sudo in case you only have one account). Then logout as current user that you want to delete, ssh again with new user and delete the old account. Of course, if you have other services still running under old user you will need to close those as well.
- Thanks Skynet, I tried it but when I do this I get the following message:userdel: user cafe_fixer is currently used by process 15945 userdel: cannot open /etc/subuid
- better kill that process by
kill -9 <pid>then run whichever you choose, until unless you terminating the process it will not let you delete the user.
- That did it. I stopped the process and then deleted the user with userdel -f cafe_fixer
- Note that the
userdelman page also says the following about the
--forceoption: "Note: This option is dangerous and may leave your system in an inconsistent state."
- 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. @skynet, please add a note about chdir.
- I never encountered issues using the
-foption. In my opinion, it is safe, just do not delete important users.
- As root user: I did:
killall -u usernamethen
deluser --remove-home username. Your solution was the only one here that worked for me. Edit: Umm... my home folder stayed. I removed that (as root) in /home/username using
rm -rf username/in when in the /home folder).
- @wlwl2 Did you use the
-foption when removing the user home directory?