-
savona pts/1 2019-03-16 09:46 . 6063 (192.168.122.1)
-
stacy pts/0 2019-03-16 17:07 . 9940 (192.168.122.1)
-
echo "Your session will be terminated in 2 minutes for maintenance." | write stacy pts/0
When you are ready to kick the user, send the SIGHUP to the users shell process. A SIGHUP signal is the same signal the process would receive when the controlling terminal is closed.
- sudo kill -HUP 9940
The number at the end of the above command is the process ID of the users shell. We found the process ID using the who command above. Sometimes there is a process that hangs. In that case we can send a SIGKILL (kill -9) to the PID. This is exactly what it sounds like. It will immediately terminate ANY process, so be careful.
- sudo kill -9 9940
My preferred way of kicking a user it to use pkill to send a SIGHUP to all of the users processes. The pkill command is a wrapper for kill and allows for signalling a process by name rather than PID (process ID).
- sudo pkill -HUP -u stacy