UNPKG

2.1 kBMarkdownView Raw
1lastb
2===
3
4列出登入系统失败的用户相关信息
5
6## 补充说明
7
8**lastb命令** 用于显示用户错误的登录列表,此指令可以发现系统的登录异常。单独执行lastb命令,它会读取位于`/var/log`目录下,名称为btmp的文件,并把该文件内容记录的登入失败的用户名单,全部显示出来。
9
10### 语法
11
12```shell
13lastb(选项)(参数)
14```
15
16### 选项
17
18```shell
19-a:把从何处登入系统的主机名称或ip地址显示在最后一行;
20-d:将IP地址转换成主机名称;
21-f<记录文件>:指定记录文件;
22-n<显示列数>或-<显示列数>:设置列出名单的显示列数;
23-R:不显示登入系统的主机名称或IP地址;
24-x:显示系统关机,重新开机,以及执行等级的改变等信息。
25```
26
27### 参数
28
29* 用户名:显示中的用户的登录列表;
30* 终端:显示从指定终端的登录列表。
31
32### 实例
33
34首次运行lastb命令会报下的错误:
35
36```shell
37lastb: /var/log/btmp: No such file or directory
38Perhaps this file was removed by the operator to prevent logging lastb info.
39```
40
41只需建立这个不存在的文件即可。
42
43```shell
44touch /var/log/btmp
45```
46
47使用ssh的登录失败不会记录在btmp文件中。
48
49```shell
50lastb | head
51root ssh:notty 110.84.129.3 Tue Dec 17 06:19 - 06:19 (00:00)
52root ssh:notty 110.84.129.3 Tue Dec 17 04:05 - 04:05 (00:00)
53root ssh:notty 110.84.129.3 Tue Dec 17 01:52 - 01:52 (00:00)
54root ssh:notty 110.84.129.3 Mon Dec 16 23:38 - 23:38 (00:00)
55leonob ssh:notty 222.211.85.18 Mon Dec 16 22:18 - 22:18 (00:00)
56leonob ssh:notty 222.211.85.18 Mon Dec 16 22:18 - 22:18 (00:00)
57root ssh:notty 110.84.129.3 Mon Dec 16 21:25 - 21:25 (00:00)
58root ssh:notty 110.84.129.3 Mon Dec 16 19:12 - 19:12 (00:00)
59root ssh:notty 110.84.129.3 Mon Dec 16 17:00 - 17:00 (00:00)
60admin ssh:notty 129.171.193.99 Mon Dec 16 16:52 - 16:52 (00:00)
61```
62
63
64<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->
\No newline at end of file