lastb
补充说明
lastb命令用于显示用户错误的登陆列表,此指令可以发觉系统的登陆异常。单独执行lastb命令linux系统下载,它会读取坐落/var/log目录下linux用户相关命令,名称为btmp的文件,并把该文件内容记录的登陆失败的用户名单linux用户相关命令linux解压命令,全部显示下来。
句型
lastb(选项)(参数)
选项
-a:把从何处登入系统的主机名称或ip地址显示在最后一行;
-d:将IP地址转换成主机名称;
-f:指定记录文件;
-n或-:设置列出名单的显示列数;
-R:不显示登入系统的主机名称或IP地址;
-x:显示系统关机,重新开机,以及执行等级的改变等信息。
参数实例
首次运行lastb命令会报下的错误:
lastb: /var/log/btmp: No such file or directory
Perhaps this file was removed by the operator to prevent logging lastb info.
只需完善这个不存在的文件即可。
touch /var/log/btmp
使用ssh的登陆失败不会记录在btmp文件中。
lastb | head
root ssh:notty 110.84.129.3 Tue Dec 17 06:19 - 06:19 (00:00)
root ssh:notty 110.84.129.3 Tue Dec 17 04:05 - 04:05 (00:00)
root ssh:notty 110.84.129.3 Tue Dec 17 01:52 - 01:52 (00:00)
root ssh:notty 110.84.129.3 Mon Dec 16 23:38 - 23:38 (00:00)
leonob ssh:notty 222.211.85.18 Mon Dec 16 22:18 - 22:18 (00:00)
leonob ssh:notty 222.211.85.18 Mon Dec 16 22:18 - 22:18 (00:00)
root ssh:notty 110.84.129.3 Mon Dec 16 21:25 - 21:25 (00:00)
root ssh:notty 110.84.129.3 Mon Dec 16 19:12 - 19:12 (00:00)
root ssh:notty 110.84.129.3 Mon Dec 16 17:00 - 17:00 (00:00)
admin ssh:notty 129.171.193.99 Mon Dec 16 16:52 - 16:52 (00:00)