• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

Linux之lastb命令

linux 搞代码 3年前 (2022-04-09) 33次浏览 已收录 0个评论

列出登入零碎失败的用户相干信息。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

搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Linux之lastb命令
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址