Linux – Log out a user and delete the account

accountslinuxusers

I am having a problem on the server (CentOS 6, Plesk 11.5) where a particular user is using a mass mailer and is blacklisting our IP address. I have tried to delete this user using:

/usr/sbin/userdel test

but it returns a message saying that the user is currently logged in. I thought ok, kill the process. So I tried:

pkill -u test

and also locked the account using:

passwd -l test

which will hopefully stop him logging into the system in future.

Still saying user is logged in. How can I log this user out to enable me to delete him off the system?

Best Answer

First grep all the 'test' user's process and kill -9 all pid's then delete the user.

pgrep -u test
ps -fp $(pgrep -u test)
killall -KILL -u test
userdel -r test
Related Question