lastb 命令用于显示用户错误的登录列表,此指令可以发现系统的登录异常。
单独执行 lastb 命令,它会读取位于 /var/log 目录下,名称为 btmp 的文件,并把该文件内容记录的登入失败的用户名单,全部显示出来。
语法格式 :lastb [参数]
常用参数 :
-a | 把从何处登入系统的主机名称或 ip 地址显示在最后一行 |
-d | 将 IP 地址转换成主机名称 |
-f | 指定记录文件 |
-n | 设置列出名单的显示列数 |
-R | 不显示登入系统的主机名称或 IP 地址 |
-x | 显示系统关机,重新开机,以及执行等级的改变等信息 |
参考实例
列出登入失败的用户记录:
[root@linuxvip ~]# lastb
root ssh:notty 192.168.3.8 Mon Apr 29 14:25 - 14:25 (00:00)
root ssh:notty 192.168.3.8 Mon Apr 29 14:25 - 14:25 (00:00)
btmp begins Mon Apr 29 14:25:16 2019
使用 - a 参数把 IP 显示在最后列:
[root@linuxvip ~]# lastb -a
root ssh:notty Mon Apr 29 14:25 - 14:25 (00:00) 192.168.3.8
root ssh:notty Mon Apr 29 14:25 - 14:25 (00:00) 192.168.3.8
btmp begins Mon Apr 29 14:25:16 2019
使用 - R 参数不显示主机名和 IP 信息:
[root@linuxvip ~]# lastb -R
root ssh:notty Mon Apr 29 14:43 - 14:43 (00:00)
root ssh:notty Mon Apr 29 14:25 - 14:25 (00:00)
btmp begins Mon Apr 29 14:25:16 2019
正文完
发表至: ⌨️系统管理
2019-05-10