1, use the W command to view the current system login user
[[Email protected] ~]# W Geneva: -:GenevaUp4: *,3Users, load average:0.00,0.01,0.05USER TTY from [email protected] IDLE jcpu PCPU whatroot pts/0 192.168.1.100 Geneva: - 4.00s0.06s0. 02s wlxj2 pts/1 192.168.1.100 Geneva: - -.00s0.00s0.00s-Bashrusky pts/2 192.168.1.100 Geneva: - 5.00s0.01s0.01s-Bash[[email protected]~]#
user-logged in User name
tty-system-assigned terminal number after login
from-remote host name, where to log in from
[Email protected]-when to login
How long the idle-is idle, indicating when the user is idle. This is a timer that will be reset once the user performs any action
The time taken by all processes jcpu-and the terminal (TTY) connection, which does not include the past background job time, but includes the time occupied by the currently running background job
Pcpu-refers to the time taken by the current process (that is, the process displayed in the What item)
what-the command line that is currently running the process
2, use the ps-u username command to view the user process, and then kill the corresponding user's sshd process
[[Email protected] ~]# PS-u lxj2 PID TTY time CMD3143?xx:xx:xxsshd3144pts/1 xx:xx:xxBash[[email protected]~]# Kill-9 3143[[Email protected]~]# PS-u lxj2 PID TTY time Cmd[[email protected]~]# WGeneva:Ten: -Up5: $,2Users, load average:0.00,0.01,0.05USER TTY from [email protected] IDLE jcpu PCPU whatroot pts/0 192.168.1.100 Geneva: - 1.00s0.17s0. 00s Wrusky pts/2 192.168.1.100 Geneva:Geneva 1: 07m0.00s0.00s-Bash[[email protected]~]#
3, there is another way to use the Pkill command to terminate the user connection
[[Email protected] ~]# W .: -: AUp8: *,3Users, load average:0.00,0.01,0.05USER TTY from [email protected] IDLE jcpu PCPU whatroot pts/0 192.168.1.100 Geneva: - 6.00s0.18s0. 01s wlxj2 pts/1 192.168.1.100 .: - 3.00s0.02s0.02s-Bashrusky pts/2 192.168.1.100 Geneva:Geneva 3: 45m0.00s0.00s-Bash[[email protected]~]# pkill-kill-t pts/1[[Email protected]~]# W .: the:GenevaUp8: $,2Users, load average:0.00,0.01,0.05USER TTY from [email protected] IDLE jcpu PCPU whatroot pts/0 192.168.1.100 Geneva: - 0.00s0.18s0. 00s Wrusky pts/2 192.168.1.100 Geneva:Geneva 3: 46m0.00s0.00s-Bash[[email protected]~]# pkill-kill-t pts/2[[Email protected]~]# W .: the: -Up8: $,1User, load Average:0.00,0.01,0.05USER TTY from [email protected] IDLE jcpu PCPU whatroot pts/0 192.168.1.100 Geneva: - 6.00s0.19s0. 01s W[[email protected]~]#
A disconnected user is interrupted in a Linux system