The problem is as follows: clear all users except the current login user. Result: 23: 00: 17up1: 08,1 user, loadaverage: 0.02, 0.05, 0.02 USERTTYFROM & n
The problem is as follows:
Clear all users except the current login user
Processing result:
23:00:17 up, 1 user, load average: 0.02, 0.05, 0.02
User tty from login @ IDLE JCPU PCPU WHAT
Root pts/1 192.168.1.100 0.00 s 10.75 s 0.00 s w
Only yourself is left on the machine :)
Method:
- #! /Bin/bash a = 'echo $0 | sed's /.. \(... \). */\ 1/''' for I in 'w | awk-v B = $ a' NR> 2 {if ($ NF! ~ B) print $2} ''Do echo $ I fuser-k/dev/$ I done
Practice:
, Pts/1 is the current user, that is, the user to be retained.
Execute the script:./kill. sh (this script is the script given above, and the script name is defined by yourself)
, All connections except for the command execution are interrupted.