当前位置:   article > 正文

【Linux】一步一步学Linux——lastb命令(99)_btmp begins tue aug 1 03:34:01 2023

btmp begins tue aug 1 03:34:01 2023

00. 目录

01. 命令概述

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

02. 命令格式

lastb [选项] [参数]
  • 1

03. 常用选项

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

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

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 ~]# 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

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 ~]# 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

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 ~]# 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

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 ~]# 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

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 ~]# 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

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 ~]# 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

05. 附录

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小惠珠哦/article/detail/862927
推荐阅读
相关标签
  

闽ICP备14008679号