1、users命令 - 查看当前登录用户名
[root@localhost shell]# users root
2、who命令 - 查看登录用户的信息
[root@localhost ~]# who root pts/0 2024-11-18 09:04 (192.168.9.103)
3、w命令 - 查看登录用户的详细信息
列出过去1分钟 5分钟 15分钟的负载情况
[root@localhost ~]# w 14:06:19 up 5:04, 1 user, load average: 0.00, 0.01, 0.05 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root pts/0 192.168.9.103 09:04 3.00s 0.15s 0.00s w
4、last命令 - 查看登录记录
注意: last通过查询日志文件获取登录信息,日志文件很容易被黑客篡改,不能单纯以该命令判断系统有无被恶意入侵
[root@localhost ~]# last root pts/0 192.168.9.103 Mon Nov 18 09:04 still logged in reboot system boot 3.10.0-1160.el7. Mon Nov 18 09:01 - 14:07 (05:06)
5、剔除可疑用户
[root@localhost ~]# who root pts/0 2024-11-18 09:04 (192.168.9.103) zth pts/1 2024-11-18 14:10 (192.168.9.103) # 找到可疑用户登录终端对应的进程pid [root@localhost ~]# ps aux|grep pts/1 | grep -v grep zth 5693 0.0 0.0 160988 2388 ? S 14:10 0:00 sshd: zth@pts/1 zth 5697 0.0 0.0 116884 3308 pts/1 Ss+ 14:10 0:00 -bash # 强制结束该进程 [root@localhost ~]# kill -9 5697