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
相关推荐
-
mysql5.7编译安装和debug调试(其他版本大同小异)
mysql5.7编译安装和debug调试(其他版本大同小异)2025-04-23 00:48:45 -
面试题:Nginx 是如何实现高并发?常见的优化手段有哪些?
面试题:Nginx 是如何实现高并发?常见的优化手段有哪些?2025-04-23 00:38:05 -
如何在PHP中使用Smarty?2025-04-23 00:24:56
-
基于Java的ORM框架对MySQL的性能影响分析2025-04-22 02:46:48
-
PHP读取文件内容的五种方式2025-04-22 02:26:20