Last Updated on 2021-10-17 by Clay
If we use ssh
command to connect to remote server, but did not log out normally (for example, suddenly disconnected), when we enter next time, we may find that the server is full of our own usernames.
The following is the screen I see using the w
command:
I must say that looks a bit an eye-catching.
If you want to logout/logoff these users, you can use pkill
command to do it. That is which topic I want to record today.
pkill
By the way, in addition to logout users, the pkill
command can also be used to kill processes.
Kill the process with the keyword test
pkill test
Kill the process whose user is user01 with the keyword test
pkill -u user01 test
The above is a basic pkill
introduction, the following is how to logout user.
Logout user whose TTY is pts/0
sudo pkill -kill -t pts/0
In this way, user whose TTY (teletype) is pts/0 can be logout.
You can logout any user you want if you have root permission.
References
- https://linux.die.net/man/1/pkill
- https://linuxize.com/post/pkill-command-in-linux/
- https://www.cyberciti.biz/faq/linux-logout-user-howto/