linux中的last命令介绍

last 命令:

功能说明:列出目前与过去登入系统的用户相关信息。

========测试环境: Fedora Core 6.0;内核:2.6.18========

#last用了显示用户登录情况。以下是直接显示固定行数的记录。kkk是新建的用户。

[kkk@localhost ~]$ last -6

kkk pts/2 :0.0 Thu Jul 26 20:48 still logged in

kkk pts/2 :0.0 Thu Jul 26 20:21 – 20:21 (00:00)

kkk :0 Thu Jul 26 20:21 still logged in

reboot system boot 2.6.18-1.2798.fc Thu Jul 26 20:20 (00:41)

kkk pts/2 :0.0 Thu Jul 26 11:16 – 11:46 (00:30)

kkk pts/2 :0.0 Thu Jul 26 10:18 – 10:18 (00:00)

wtmp begins Sun Jul 1 15:17:08 2007

#默认是显示wtmp的记录,btmp能显示的更详细,可以显示远程登录,例如ssh登录。

[root@localhost ~]# last -n 15 -f /var/log/btmp

kkk :0 Thu Jul 26 20:21 still logged in

klot tty1 Fri Jul 20 22:27 gone – no logout

np962e76 tty1 Fri Jul 20 22:26 – 22:27 (00:00)

klot tty1 Fri Jul 20 22:26 – 22:26 (00:00)

root :0 Fri Jul 20 22:22 – 20:21 (5+21:58)

klot :0 Fri Jul 20 22:22 – 22:22 (00:00)

root tty1 Fri Jul 20 20:58 – 22:26 (01:28)

klot tty1 Fri Jul 20 20:58 – 20:58 (00:00)

klot tty1 Fri Jul 20 20:57 – 20:58 (00:00)

klot tty1 Fri Jul 20 20:57 – 20:57 (00:00)

klot tty1 Fri Jul 20 20:57 – 20:57 (00:00)

klot tty1 Fri Jul 20 20:57 – 20:57 (00:00)

reboot tty1 Fri Jul 20 20:55 – 20:57 (00:02)

root tty1 Fri Jul 20 20:54 – 20:55 (00:00)

root tty1 Fri Jul 20 20:54 – 20:54 (00:00)

btmp begins Mon Apr 30 22:05:54 2007

#显示特定tty口的登录,1是tty1的登录情况,看的很清楚的。 np962e76 和 lkdjflkj 和klot其实都没有登

#录成功,我是把密码忘记了。前面两个用户,是根本不存在的,但是也有记录。

[root@localhost ~]# last -n 15 -f /var/log/btmp 1

klot tty1 Fri Jul 20 22:27 gone – no logout

np962e76 tty1 Fri Jul 20 22:26 – 22:27 (00:00)

klot tty1 Fri Jul 20 22:26 – 22:26 (00:00)

root tty1 Fri Jul 20 20:58 – 22:26 (01:28)

klot tty1 Fri Jul 20 20:58 – 20:58 (00:00)

klot tty1 Fri Jul 20 20:57 – 20:58 (00:00)

klot tty1 Fri Jul 20 20:57 – 20:57 (00:00)

klot tty1 Fri Jul 20 20:57 – 20:57 (00:00)

klot tty1 Fri Jul 20 20:57 – 20:57 (00:00)

reboot tty1 Fri Jul 20 20:55 – 20:57 (00:02)

root tty1 Fri Jul 20 20:54 – 20:55 (00:00)

root tty1 Fri Jul 20 20:54 – 20:54 (00:00)

root tty1 Fri Jul 20 20:54 – 20:54 (00:00)

lkdjflkj tty1 Fri Jul 20 20:54 – 20:54 (00:00)

klot tty1 Fri Jul 20 20:53 – 20:54 (00:00)

btmp begins Mon Apr 30 22:05:54 2007

#显示特定用户的登录情况。

[root@localhost ~]# last -n 15 -f /var/log/btmp klot

klot tty1 Fri Jul 20 22:27 gone – no logout

klot tty1 Fri Jul 20 22:26 – 22:26 (00:00)

klot :0 Fri Jul 20 22:22 – 22:22 (00:00)

klot tty1 Fri Jul 20 20:58 – 20:58 (00:00)

klot tty1 Fri Jul 20 20:57 – 20:58 (00:00)

klot tty1 Fri Jul 20 20:57 – 20:57 (00:00)

klot tty1 Fri Jul 20 20:57 – 20:57 (00:00)

klot tty1 Fri Jul 20 20:57 – 20:57 (00:00)

klot tty1 Fri Jul 20 20:53 – 20:54 (00:00)

klot tty1 Fri Jul 20 20:53 – 20:53 (00:00)

klot tty1 Fri Jul 20 20:53 – 20:53 (00:00)

klot tty1 Fri Jul 20 20:53 – 20:53 (00:00)

klot tty1 Fri Jul 20 20:52 – 20:53 (00:00)

klot tty1 Fri Jul 20 20:52 – 20:52 (00:00)

klot tty1 Fri Jul 20 20:52 – 20:52 (00:00)

btmp begins Mon Apr 30 22:05:54 2007

#显示登录登出的记录,-x。

[root@localhost ~]# last -n 15 -f /var/log/btmp klot -x

klot tty1 Fri Jul 20 22:27 gone – no logout

klot tty1 Fri Jul 20 22:26 – 22:26 (00:00)

klot :0 Fri Jul 20 22:22 – 22:22 (00:00)

klot tty1 Fri Jul 20 20:58 – 20:58 (00:00)

klot tty1 Fri Jul 20 20:57 – 20:58 (00:00)

klot tty1 Fri Jul 20 20:57 – 20:57 (00:00)

klot tty1 Fri Jul 20 20:57 – 20:57 (00:00)

klot tty1 Fri Jul 20 20:57 – 20:57 (00:00)

klot tty1 Fri Jul 20 20:53 – 20:54 (00:00)

klot tty1 Fri Jul 20 20:53 – 20:53 (00:00)

klot tty1 Fri Jul 20 20:53 – 20:53 (00:00)

klot tty1 Fri Jul 20 20:53 – 20:53 (00:00)

klot tty1 Fri Jul 20 20:52 – 20:53 (00:00)

klot tty1 Fri Jul 20 20:52 – 20:52 (00:00)

klot tty1 Fri Jul 20 20:52 – 20:52 (00:00)

btmp begins Mon Apr 30 22:05:54 2007

#-i显示特定ip登录的情况。跟踪用。

[root@localhost ~]# last -n 15 -i 127.0.0.1 -f /var/log/btmp klot

klot tty1 0.0.0.0 Fri Jul 20 22:27 gone – no logout

klot tty1 0.0.0.0 Fri Jul 20 22:26 – 22:26 (00:00)

klot :0 0.0.0.0 Fri Jul 20 22:22 – 22:22 (00:00)

klot tty1 0.0.0.0 Fri Jul 20 20:58 – 20:58 (00:00)

klot tty1 0.0.0.0 Fri Jul 20 20:57 – 20:58 (00:00)

klot tty1 0.0.0.0 Fri Jul 20 20:57 – 20:57 (00:00)

klot tty1 0.0.0.0 Fri Jul 20 20:57 – 20:57 (00:00)

klot tty1 0.0.0.0 Fri Jul 20 20:57 – 20:57 (00:00)

klot tty1 0.0.0.0 Fri Jul 20 20:53 – 20:54 (00:00)

klot tty1 0.0.0.0 Fri Jul 20 20:53 – 20:53 (00:00)

klot tty1 0.0.0.0 Fri Jul 20 20:53 – 20:53 (00:00)

klot tty1 0.0.0.0 Fri Jul 20 20:53 – 20:53 (00:00)

klot tty1 0.0.0.0 Fri Jul 20 20:52 – 20:53 (00:00)

klot tty1 0.0.0.0 Fri Jul 20 20:52 – 20:52 (00:00)

klot tty1 0.0.0.0 Fri Jul 20 20:52 – 20:52 (00:00)

btmp begins Mon Apr 30 22:05:54 2007

---------------------

其他参数没有特别说明,自行参考man。

如果雨后还是雨,如果忧伤过后还是忧伤,

linux中的last命令介绍

相关文章:

你感兴趣的文章:

标签云: