
我經常使用該last
命令來檢查我的系統是否有未經授權的登錄,該命令:
last -Fd
給我登入訊息,其中我有顯示 ip 的遠端登入資訊。
從man last
:
-F Print full login and logout times and dates.
-d For non-local logins, Linux stores not only the host name of the remote host but its IP number as well. This option translates the IP
number back into a hostname.
問題:
我的一個系統只顯示幾天的登入情況。這是為什麼?last
只給我幾天時間我能做什麼?
這是有問題的輸出:
root ~ # last -Fd
user pts/0 111-111-111-111. Wed Oct 8 20:05:51 2014 still logged in
user pts/0 host.lan Mon Oct 6 09:52:01 2014 - Mon Oct 6 09:53:41 2014 (00:01)
user pts/0 host.lan Sat Oct 4 10:11:39 2014 - Sat Oct 4 10:12:13 2014 (00:00)
user pts/0 host.lan Sat Oct 4 09:31:07 2014 - Sat Oct 4 10:11:00 2014 (00:39)
user pts/0 host.lan Sat Oct 4 09:26:04 2014 - Sat Oct 4 09:28:16 2014 (00:02)
wtmp begins Sat Oct 4 09:26:04 2014
答案1
很可能logrotate
已經歸檔了感興趣的日誌並打開了一個新日誌。如果您有較舊的wtmp
文件,請指定其中之一,例如:
last -f /var/log/wtmp-20141001
答案2
“last”指令從 /var/log/wtmp 檔案讀取資料。如果您啟用了 logrotate 服務,它可能會輪換 wtmp 檔案。檢查 /var/log 目錄中是否有 wtmp.1 或 wtmp.1.gz 檔案。如果您有它(或與下一個數字更相似:wtmp.2 wtmp.3 等),則表示 wtmp 日誌已輪換。然後您可以調整/停用旋轉或使用“last -f wtmp_file”命令檢查較舊的資料。