列出登入系統(tǒng)失敗的用戶(hù)相關(guān)信息
lastb命令 用于顯示用戶(hù)錯(cuò)誤的登錄列表,此指令可以發(fā)現(xiàn)系統(tǒng)的登錄異常。單獨(dú)執(zhí)行l(wèi)astb命令,它會(huì)讀取位于/var/log
目錄下,名稱(chēng)為btmp的文件,并把該文件內(nèi)容記錄的登入失敗的用戶(hù)名單,全部顯示出來(lái)。
lastb(選項(xiàng))(參數(shù))
-a:把從何處登入系統(tǒng)的主機(jī)名稱(chēng)或ip地址顯示在最后一行;
-d:將IP地址轉(zhuǎn)換成主機(jī)名稱(chēng);
-f<記錄文件>:指定記錄文件;
-n<顯示列數(shù)>或-<顯示列數(shù)>:設(shè)置列出名單的顯示列數(shù);
-R:不顯示登入系統(tǒng)的主機(jī)名稱(chēng)或IP地址;
-x:顯示系統(tǒng)關(guān)機(jī),重新開(kāi)機(jī),以及執(zhí)行等級(jí)的改變等信息。
首次運(yùn)行l(wèi)astb命令會(huì)報(bào)下的錯(cuò)誤:
lastb: /var/log/btmp: No such file or directory
Perhaps this file was removed by the operator to prevent logging lastb info.
只需建立這個(gè)不存在的文件即可。
touch /var/log/btmp
使用ssh的登錄失敗不會(huì)記錄在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)