sudo deluser --remove-home your_user deletes the home directories as well as the user entries.
The additional option --remove-all-files even removes all the files owned by the user.
sudo deluser --remove-home your_user deletes the home directories as well as the user entries.
The additional option --remove-all-files even removes all the files owned by the user.
Now that you have deleted the user accounts, neither deluser nor userdel will know anything about them or their home directories, since the corresponding /etc/passwd entries are gone. Just manually delete the directories once you have backed up any valuable data:
sudo rm -r /home/user1 /home/user2 ...
You could, of course, have deleted the directories while deleting the user like the other answers suggested.
Videos
Does `userdel` delete the home directory?
Does deleting a user remove their cron jobs?
How do I undo a user deletion?
hi good people
how to delete a created user properly ? , i have created a new user due to testing and i followed instructions from the web on how to delete user , but the user still showing in the login screen
. how to properly delete a user ?
Probably because you do not use the userdel command as superuser (root) or other privileged user. Try:
sudo userdel accountname
As stated in several comments it is also possible to remove the homedirectory configured while removing the useraccount using:
sudo userdel -r accountname
A more modern way to do this is with the deluser command:
sudo deluser --remove-all-files $USER_TO_DELETE
See the manual page for details.
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.
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.