# last
root pts/2 192.168.0.142 Sun Feb 16 20:21 still logged in
kimu pts/2 172.16.0.10 Sun Feb 16 20:21 - 20:21
(00:00)
y-kimura pts/1 192.168.0.142 Sun Feb 16 20:18 - 20:20 (00:02)
・・・・・・ 省略 ……
# lastlog
…… 省略 ……
kimu pts/2 172.16.0.10 Sun Feb 16 20:21:28
+0900 2003
このうち、ユーザーkimuのアクセス履歴の消去を行う。
# ./zap kimu
Zap2!
消去完了。もう一度last、lastlogコマンドを実行して確認してみる。
# last
root pts/2 192.168.0.142 Sun Feb 16 20:21 still logged in
y-kimura pts/1 192.168.0.142 Sun Feb 16 20:18 - 20:20 (00:02)
% last
root pts/2 192.168.0.142 Sun Feb 16 20:21 still logged in
kimu pts/2 172.16.0.10 Sun Feb 16 20:21 - 20:21 (00:00)
y-kimura pts/1 192.168.0.142 Sun Feb 16 20:18 - 20:20 (00:02)
y-kimura pts/0 192.168.0.142 Sun Feb 16 10:45 - 02:42 (15:56)
y-kimura pts/0 192.168.0.142 Thu Feb 13 01:23 - 03:56 (02:32)
…… 省略 ……
例:最後にログインしたユーザーから3行分のみを表示
% last -3
root pts/2 192.168.0.142 Sun Feb 16 20:21 still logged in
kimu pts/2 172.16.0.10 Sun Feb 16 20:21 - 20:21 (00:00)
y-kimura pts/1 192.168.0.142 Sun Feb 16 20:18 - 20:20 (00:02)
例:ユーザーkimuのログイン履歴を調べる。
% last kimu
kimu pts/0 172.16.0.10 Mon Feb 17 02:42 still logged in
kimu pts/2 172.16.0.10 Sun Feb 16 20:21 - 20:21 (00:00)
(3)lastlog (各ユーザーの最終ログイン日時を表示)
lastlog(lastlogin)コマンドで、各ユーザーの最終ログイン日時を表示する。
例:全ユーザーの情報を表示
% lastlog
Username Port From Latest
root pts/2 192.168.30.142 Sun Feb 16 20:21:45 +0900 2003
bin **Never logged in**
…… 途中省略 …… y-kimura pts/3 192.168.30.142
Mon Feb 17 03:12:37 +0900 2003
kimu pts/2 192.168.30.142 Sun Feb 16 20:21:28 +0900 2003
例:ユーザーkimuの情報のみ表示
% lastlog -u kimu
Username Port From Latest
kimu pts/2 192.168.30.142 Sun Feb 16 20:21:28 +0900 2003
例:過去1日にアクセスしたユーザーのみ表示
% lastlog -t 1
Username Port From Latest
root pts/2 192.168.30.142 Sun Feb 16 20:21:45 +0900 2003
y-kimura pts/3 192.168.30.142 Mon Feb 17 03:12:37 +0900 2003
kimu pts/2 192.168.30.142 Sun Feb 16 20:21:28 +0900 2003
# less /var/log/messages
Feb 16 04:02:19 www syslogd 1.4.1: restart.
Feb 16 10:45:50 www sshd(pam_unix)[23922]: session opened for user
y-kimura by (uid=0)
# tail -3 /var/log/messages
Feb 16 14:56:10 www sshd(pam_unix)[24799]: session closed for
user y-kimura
Feb 16 14:56:15 www sshd(pam_unix)[24807]: session opened for
user y-kimura by (uid=0)
Feb 16 16:26:33 www su(pam_unix)[24954]: session opened for
user root by y-kimura(uid=500)
例:/var/log/messagesに出力される内容を随時表示(-fオプション)
# tail -f /var/log/messages
Feb 16 10:45:50 www sshd(pam_unix)[23922]: session closed for
user y-kimura
Feb 16 10:45:56 www sshd(pam_unix)[23930]: session opened for
user y-kimura by (uid=0)
Feb 16 14:56:09 www sshd(pam_unix)[24799]: session opened for
user y-kimura by (uid=0)
Feb 16 14:56:10 www sshd(pam_unix)[24799]: session closed for
user y-kimura
Feb 16 14:56:15 www sshd(pam_unix)[24807]: session opened for
user y-kimura by (uid=0)
Feb 16 16:26:33 www su(pam_unix)[24954]: session opened for
user root by y-kimura(uid=500)
# grep named /var/log/messages
Jan 26 11:17:31 www named[689]: shutting down
Jan 26 11:17:31 www named[689]: stopping command channel on
127.0.0.1#953
Jan 26 11:17:31 www named[689]: no longer listening on 127.0.0.1#53