I'm trying to delete a user logged into my ubuntu system. Let's call the user bob.
I'm running
sudo userdel -r bob
The response I get is
userdel: user bob is currently logged in
So I run
ps -u bob
To find his bash session to kill it. But I'm not seeing it - I'm looking for something like:
13205 pts/0 00:00:00 bash
(Which is my session) but I don't see another one:
What command can I run to find out what this user is logged in as?
Edit:
who bob
gives no result (to stdout at least)
last bob
gives a result three days ago - but running
sudo userdel -r bob
Still gives the same result.
Edit
who
only gives my login.
Edit
root@machine:~# sudo userdel -rf bob
userdel: user bob is currently logged in
userdel: warning: can't remove /var/mail/bob: No such file or directory
userdel: error removing directory /
root@machine:~# sudo userdel -rf bob
userdel: user 'bob' does not exist
This seems like it was not a correct type of user - is that correct?
The
who
command should work.Or you could display all processes belong to bob with
ps -au bob
.Run ps command:
then press '/bob' and press enter(to search):
Does
sudo userdel -rf bob
work? If not, what error does it give?quick and dirty
ps fuxaw |grep ^bob | awk '{print $2}' | xargs kill -9
this will kill all bobs processes, so you can proceed with deleting the account.
track down the session off the user
and then kill them.
Or, i you are feeling confident:
Otherwise, you could try forcing the userdel by adding the -f option.