说明

  last命令用于显示用户登录日志列表。从日志文件/var/log/wtmp读取信息。

格式

  last [option]

常用参数
  • -n:显示指定结果的行数,其实也可以省略该参数
示例
[root@localhost ~]# last
root     pts/4        192.168.71.1     Mon May 14 04:42   still logged in   
root     pts/3        192.168.71.1     Mon May 14 04:42   still logged in   
root     pts/2        192.168.71.1     Mon May 14 03:45   still logged in   
......

wtmp begins Sat May  5 13:29:37 2018


[root@localhost ~]# last -n 5 #使用-n参数
root     pts/4        192.168.71.1     Mon May 14 04:42   still logged in   
root     pts/3        192.168.71.1     Mon May 14 04:42   still logged in   
root     pts/2        192.168.71.1     Mon May 14 03:45   still logged in   
root     pts/1        192.168.71.1     Mon May 14 03:45   still logged in   
root     pts/0        192.168.71.1     Mon May 14 03:05   still logged in   

wtmp begins Sat May  5 13:29:37 2018


[root@localhost ~]# last -5 #直接指定行数,前面有-
root     pts/4        192.168.71.1     Mon May 14 04:42   still logged in   
root     pts/3        192.168.71.1     Mon May 14 04:42   still logged in   
root     pts/2        192.168.71.1     Mon May 14 03:45   still logged in   
root     pts/1        192.168.71.1     Mon May 14 03:45   still logged in   
root     pts/0        192.168.71.1     Mon May 14 03:05   still logged in   

wtmp begins Sat May  5 13:29:37 2018