有些人比较狡猾,做了坏事拒不承认。但是,在 Linux 里,每个用户的登录信息都会记录起来,这样查找相关人员的责任就有所依据。
last命令可用于显示特定用户登录系统的历史记录。如果没有指定任何参数,则显示所有用户的历史信息。在默认情况下,这些信息(所显示的信息)将来源于/var/log/wtmp文件。该命令的输出结果包含以下几列信息:
用户名称
tty设备号
历史登录时间日期
登出时间日期
总工作时间 [alvin@VM_0_16_centos ~]$ last alvin pts/5 116.199.*.Sun Dec 9 11:53 still logged in kate pts/4 116.199.*.Sun Dec 9 11:08 still logged in harry pts/3 116.199.*.Sun Dec 9 11:06 still logged in alvin pts/2 116.199.*.Sun Dec 9 11:05 still logged in root pts/1 116.199.*.Sun Dec 9 11:05 still logged in alvin pts/0 116.199.*.Sun Dec 9 07:25 still logged in alvin pts/0 116.199.*.Sat Dec 8 20:42 - 23:10 (02:28) alvin pts/0 119.33.*.Mon Dec 3 20:50 - 23:51 (1+03:01) alvin pts/0 119.33.*.Thu Nov 29 20:20 - 22:45 (02:24) alvin pts/0 223.104.*.Thu Nov 29 06:46 - 07:00 (00:14) alvin pts/0 223.104.*.Wed Nov 28 20:45 - 22:27 (01:42) alvin pts/1 14.25..Sun Nov 25 19:50 - 21:09 (01:18) alvin pts/0 119.33.*.Sun Nov 25 16:32 - 21:40 (05:07)
如果我们只想看某个人的历史记录,则在last后跟上对应的用户名即可:
[alvin@VM_0_16_centos ~]$ last alvin
alvin pts/5 116.199.***.** Sun Dec 9 11:53 still logged in
alvin pts/2 116.199.***.** Sun Dec 9 11:05 still logged in
alvin pts/0 116.199.***.** Sun Dec 9 07:25 still logged in
alvin pts/0 116.199.***.** Sat Dec 8 20:42 - 23:10 (02:28)
alvin pts/0 119.33.***.** Mon Dec 3 20:50 - 23:51 (1+03:01)
alvin pts/0 119.33.***.** Thu Nov 29 20:20 - 22:45 (02:24)
alvin pts/0 223.104.***.** Thu Nov 29 06:46 - 07:00 (00:14)
alvin pts/0 223.104.***.** Wed Nov 28 20:45 - 22:27 (01:42)
[attach]53597[/attach]