Linux之lastb命令
列出登入系统失败的用户相关信息。lastb命令 用于显示用户错误的登录列表,此指令可以发现系统的登录异常。单独执行lastb命令,它会读取位于/var/log目录下,名称为btmp的文件,并把该文件内容记录的登入失败的用户名单,全部显示出来。
命令语法
lastb [选项] [参数]
命令选项
- -a:把从何处登入系统的主机名称或ip地址显示在最后一行;
- -d:将IP地址转换成主机名称;
- -f<记录文件>:指定记录文件;
- -n<显示列数>或-<显示列数>:设置列出名单的显示列数;
- -R:不显示登入系统的主机名称或IP地址;
- -x:显示系统关机,重新开机,以及执行等级的改变等信息。
命令参数
- 用户名:显示中的用户的登录列表;
- 终端:显示从指定终端的登录列表。
使用ssh的登录失败不会记录在btmp文件中。
> lastb | head
root ssh:notty 120.132.112.75 Sun Apr 11 22:18 - 22:18 (00:00)
root ssh:notty 185.36.81.44 Sun Apr 11 22:18 - 22:18 (00:00)
root ssh:notty 101.89.138.113 Sun Apr 11 22:18 - 22:18 (00:00)
admin1 ssh:notty 123.21.35.183 Sun Apr 11 22:18 - 22:18 (00:00)
admin1 ssh:notty 123.21.35.183 Sun Apr 11 22:17 - 22:17 (00:00)
adria ssh:notty 132.232.32.203 Sun Apr 11 22:17 - 22:17 (00:00)
adria ssh:notty 132.232.32.203 Sun Apr 11 22:17 - 22:17 (00:00)
root ssh:notty 115.79.35.110 Sun Apr 11 22:17 - 22:17 (00:00)
user ssh:notty 103.248.31.50 Sun Apr 11 22:17 - 22:17 (00:00)
user ssh:notty 103.248.31.50 Sun Apr 11 22:17 - 22:17 (00:00)
lastb指令,它会读取位于/var/log/btmp的文件,并把该文件内容记录的登入系统失败的用户名单,全部显示出来。btmp是二进制文件,所以用last -f /var/log/btmp结果一样。
找出指定用户名登录失败的记录
> lastb root | head
root ssh:notty 123.21.35.183 Sun Apr 11 22:25 - 22:25 (00:00)
root ssh:notty 123.21.35.183 Sun Apr 11 22:24 - 22:24 (00:00)
root ssh:notty 123.21.35.183 Sun Apr 11 22:24 - 22:24 (00:00)
root ssh:notty 120.132.112.75 Sun Apr 11 22:24 - 22:24 (00:00)
root ssh:notty 81.69.251.186 Sun Apr 11 22:23 - 22:23 (00:00)
root ssh:notty 123.21.35.183 Sun Apr 11 22:23 - 22:23 (00:00)
root ssh:notty 123.21.35.183 Sun Apr 11 22:22 - 22:22 (00:00)
root ssh:notty 81.69.251.186 Sun Apr 11 22:21 - 22:21 (00:00)
root ssh:notty 120.132.112.75 Sun Apr 11 22:21 - 22:21 (00:00)
root ssh:notty 120.132.112.75 Sun Apr 11 22:18 - 22:18 (00:00)
清除lastb对应的文件内容
> echo > /var/log/btmp
相关推荐
-
「PHP」MVC框架是什么?为什么要用它2025-02-25 00:25:41
-
如何用PHP写一个比较安全的API系统(实现)2025-02-25 00:19:49
-
php 解析url获取相关信息2025-02-25 00:15:37
-
mysql命令总结和PyMysql2025-02-25 00:11:35
-
MySQL特性:深入理解ICP2025-02-25 00:11:07