【Linux】一步一步学Linux——lastb命令(99)

00. 目录

01. 命令概述

lastb命令用于显示用户错误的登录列表,此指令可以发现系统的登录异常。单独执行lastb命令,它会读取位于/var/log目录下,名称为btmp的文件,并把该文件内容记录的登入失败的用户名单,全部显示出来。

02. 命令格式

lastb [选项] [参数]

03. 常用选项

lastb 与last命令类似,lastb命令查找、var/log/btmp 文件,此文件列出了所有登录系统失败的用户的信息

必要参数
-n 显示最近登录信息的行数
-t 根据登陆的时间显示指定用户的登录状态
-R 简略显示主机名区域
-a 在最后一列显示主机名称
-d 对于非本地登录的用户,将显示的IP地址转换为主机名
-i 类似于“-d” 的选项,将显示的主机名称转换为IP地址
-o 读取旧的类型的wtmp 文件
-x 显示系统登录等级
--help 显示帮助信息
--version 显示版本显示

04. 参考示例

4.1 列出登入失败的用户记录

[root@itcast ~]# lastb
root     pts/1                         Fri Aug  2 21:00 - 21:00  (00:00)    
root     pts/1                         Thu Aug  1 21:27 - 21:27  (00:00)    

btmp begins Thu Aug  1 21:27:11 2019
[root@itcast ~]# 

lastb指令,它会读取位于**/var/log/btmp的文件,并把该文件内容记录的登入系统失败**的用户名单,全部显示出来。btmp是二进制文件,所以用 last -f /var/log/btmp 结果一样。

4.2 使用-a参数把IP显示在最后列

[root@itcast ~]# lastb -a
root     pts/1        Fri Aug  2 21:00 - 21:00  (00:00)     
root     pts/1        Thu Aug  1 21:27 - 21:27  (00:00)     

btmp begins Thu Aug  1 21:27:11 2019
[root@itcast ~]# 

4.3 使用-R参数不显示主机名和IP信息

[root@itcast ~]# lastb -R 
root     pts/1        Fri Aug  2 21:00 - 21:00  (00:00)    
root     pts/1        Thu Aug  1 21:27 - 21:27  (00:00)    

btmp begins Thu Aug  1 21:27:11 2019
[root@itcast ~]# 

4.4 显示6条登录失败的信息

[root@itcast ~]# lastb -6
root     pts/1                         Fri Aug  2 21:00 - 21:00  (00:00)    
root     pts/1                         Thu Aug  1 21:27 - 21:27  (00:00)    

btmp begins Thu Aug  1 21:27:11 2019
[root@itcast ~]# 

4.5 显示3条登录失败的信息

[root@itcast ~]# lastb -n 3
root     pts/1                         Fri Aug  2 21:00 - 21:00  (00:00)    
root     pts/1                         Thu Aug  1 21:27 - 21:27  (00:00)    

btmp begins Thu Aug  1 21:27:11 2019
[root@itcast ~]# 

4.6 显示2条关于root用户登录失败的信息

[root@itcast ~]# lastb -n 2 root
root     pts/1                         Fri Aug  2 21:00 - 21:00  (00:00)    
root     pts/1                         Thu Aug  1 21:27 - 21:27  (00:00)    

btmp begins Thu Aug  1 21:27:11 2019
[root@itcast ~]# 

05. 附录

参考:【Linux】一步一步学Linux系列教程汇总

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值