I had an issue with my Ubuntu recently that the computer was not stopping screesaver and didn’t show me the login page after a screenlock. Most people usually try to forcefully shutdown by pressing and holding the power button for about 10 seconds. This is not a good choice specially when you have some services on that machine or having some other users logged in through SSH to that computer.
In this article I will briefly explain how to logout a specific user remotely through SSH without touching or terminating any service or any other user.
Before everything, you should find a way to have SSH connection to the target computer (from another computer or another user on the same computer) and you should be a sudoer. You can add a user to sudoer list by following “Add user or group to sudoers file” tutorial.
For this purpose you should know the username of the user that you want to force logoff/logout and for this purpose you can use the following command to find the list of usernames:
and you will get something like the following list:
In the list the username would be the first part of each line (root, bin, deamon, …).
Now it would be the time for having the final command to force logout the user:
pkill -KILL -u batman
and now the user is literally logged off.