Log out a user and delete the account
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
passwd -l <user>
doesn't stop all possible means of logging in. For example, if they log in using ssh
with public keys they can still login as they won't need a password.
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.
passwd -l <user>
does not disable the account.as gareth said the user may still can login using another authentication token such as SSH key.
to disable this account you should use
usermod --expiredate 1
this set the account expire date to 1970.
Now you should kill all processes the user is started.
running:
$pgrep -u Foo
will print all processes that the user Foo is started.
running:
$kill -9 <pid>
will sent SIGKILL
signal which kill that process. Now
Run:
$pgrep -u Foo | xargs kill -9
this will get all process ids of user Foo and kill them all.
OR:
$kill -9 -u Foo