I tried to delete a user:
# deluser someuser
Removing user `someuser' ...
Warning: group `someuser' has no more members.
userdel: user someuser is currently logged in
/usr/sbin/deluser: `/usr/sbin/userdel someuser' returned error code 8. Exiting.
I ran who
# who
myuser pts/0 2013-12-19 23:00 ...
It only shows me logged in. I really need to delete this user but I don't have their password, I have sudo password however. How can I delete it?
If you cannot remove a user that is certainly because some process are still running belong him.
First you can list his process with:
If that is the case, you can kill all his process with
Then execute
deluser
againor
In the man page of deluser, it says that an error code of 8 indicates that the perl paquet "perl-modules" is not installed, maybe you can check this...
Anyway, if you want to force deletion you can use deluser with -f option
but do it only if you don't find another way, it can produce instability... See man page for more information
I encountered the same problem when trying to delete a user that was logged in the first time I tried to delete it. To me, waiting a few seconds was the solution:
As I mentioned, the first attempt to delete the user failed for it was still logged in. I then logged out the user and repeated the
command, but the
showed up again. This time with some process ID that currently seamed to be used by "username2delete".
I checked which users are logged in and there was only one user logged in "user2stay".
I then read your posts and after 2 minutes I tried again the same command as before:
This time it worked without problems. There was no reboot necessary nor a forced
deluser
. Maybe this will help you.I encountered the same problem while trying to delete a user that was connected through a ssh session. 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.