このエントリーをはてなブックマークに追加


lastコマンドで過去のログイン履歴を見たい場合

lastコマンドを実行すると以下のようにwtmp begins Wed Oct 10 08:20:59 2012と表示され過去のログイン履歴が表示されない場合の対応方法を以下に記します。

$ last
sakura   pts/1        xxx.xxx.xxx.xxx   Wed Oct 1 09:30   still logged in   
tsubaki  pts/0        xxx.xxx.xxx.xxx   Wed Oct 1 09:10   still logged in   
sakura   pts/0        fobarhoge        Wed Oct 1 08:20 - 08:22  (00:01)    

wtmp begins Wed Oct 10 08:20:59 2012

関連資料

wtmp begins 日時の意味

lastコマンドは/var/log/wtmpファイルを使用しています。
wtmp begins Wed Oct 10 08:20:59 2012は、10/10 8:20:59に作成されたファイルを使用していることを示しています。
したがって、過去のwtmpファイルは別名として保存されています。

wtmpについて

wtmpが保存されているログディレクトリでlsした結果です。

$ ls /var/log/wtmp*
/var/log/wtmp  /var/log/wtmp.1

wtmpとwtmp.1の2つのファイルが作成されています。
wtmp.1の1は、1つ前のwtmpであることを示しています。

過去のwtmpを使用する

以下のように-fオプションを使用すればwtmpファイルを指定してlastコマンドを実行することができます。

last -f /var/log/wtmp.1
$ last -f /var/log/wtmp.1
<snip>
root     pts/2        xx.xxx.xxx.xx    Thu Jul 20 03:26 - 03:27  (00:00)    
root     pts/1        xx.xxx.xxx.xx    Thu Jul 20 02:10 - 04:03  (01:52)    
root     pts/0        xx.xxx.xxx.xx    Thu Jul 20 02:07 - 04:03  (01:55)    
reboot   system boot  2.6.18-308.el5   Thu Jul 20 02:06          (20:12)    
root     pts/0        xx.xxx.xxx.xx    Thu Jul 20 01:54 - down   (00:05)    
root     tty2                          Thu Jul 20 01:03 - down   (00:56)    
root     pts/0        sakura           Thu Jul 20 00:59 - 00:59  (00:00)    
root     tty1                          Thu Jul 20 00:59 - down   (01:00)    
<snip>

本操作はCentOSで行いましたがDebian系でも同様のファイル名およびディレクトリのはずです。



トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2015-03-20 (金) 22:28:13