last命令
来源:原创 更新时间:2018-08-26 09:43:32 作者:管理员 浏览:2184
- 命令语法
- 命令选项
-d:将IP地址转换成主机名称;
-f <记录文件>:指定记录文件。
-n <显示列数>或-<显示列数>:设置列出名单的显示列数;
-R:不显示登入系统的主机名称或IP地址;
-x:显示系统关机,重新开机,以及执行等级的改变等信息。
- 命令实例
实例1:解析
[root@sentinel ~]# last root pts/0 10.0.0.1 Sun Aug 26 05:40 still logged in reboot system boot 2.6.32-696.el6.x Sun Aug 26 05:27 - 05:40 (00:12) root pts/2 10.0.0.1 Thu Aug 23 22:01 - crash (2+07:25) root pts/0 10.0.0.1 Thu Aug 23 14:24 - 14:54 (00:30) root pts/0 10.0.0.1 Thu Aug 23 11:51 - 13:18 (01:26) reboot system boot 2.6.32-696.el6.x Thu Aug 23 11:50 - 05:40 (2+17:50) root pts/2 10.0.0.1 Thu Aug 23 09:52 - crash (01:57) root pts/0 10.0.0.1 Wed Aug 22 15:17 - 17:53 (02:35) reboot system boot 2.6.32-696.el6.x Wed Aug 22 15:17 - 05:40 (3+14:22) root pts/4 10.0.0.1 Mon Aug 13 11:32 - 11:41 (00:09) root pts/3 10.0.0.1 Mon Aug 13 11:05 - 11:41 (00:36) haha pts/3 10.0.0.201 Mon Aug 13 04:06 - 04:06 (00:00) root pts/2 10.0.0.1 Mon Aug 13 02:30 - 03:49 (01:19) root pts/1 10.0.0.1 Mon Aug 13 02:30 - 03:49 (01:19) root pts/1 10.0.0.1 Sun Aug 12 23:54 - 02:30 (02:36) root pts/3 10.0.0.1 Sun Aug 12 21:50 - 02:30 (04:39) root pts/1 10.0.0.1 Sun Aug 12 20:50 - 20:56 (00:05) root tty1 Sun Aug 12 20:45 - crash (9+18:31) root pts/2 10.0.0.1 Sun Aug 12 16:21 - 22:44 (06:22) root pts/1 10.0.0.1 Sun Aug 12 15:18 - 18:09 (02:50) root pts/0 10.0.0.1 Sun Aug 12 12:50 - 17:12 (04:22) reboot system boot 2.6.32-696.el6.x Sun Aug 12 12:50 - 05:40 (13+16:50) root pts/1 10.0.0.1 Sat Aug 11 02:06 - crash (1+10:43) root pts/0 10.0.0.1 Fri Aug 10 03:58 - 05:28 (01:30) root tty1 Fri Aug 10 03:58 - crash (2+08:51) reboot system boot 2.6.32-696.el6.x Fri Aug 10 03:56 - 05:40 (16+01:43) root pts/0 10.0.0.1 Thu Aug 9 16:40 - crash (11:16) root tty1 Thu Aug 9 16:39 - crash (11:16) reboot system boot 2.6.32-696.el6.x Thu Aug 9 16:38 - 05:40 (16+13:01) root pts/0 10.0.0.1 Wed Aug 8 20:33 - crash (20:04) root pts/1 10.0.0.1 Wed Aug 8 09:07 - 03:22 (18:15) root pts/1 10.0.0.1 Wed Aug 8 08:08 - 09:06 (00:58) root pts/0 10.0.0.1 Wed Aug 8 02:58 - 09:34 (06:36) root tty1 Wed Aug 8 09:29 - crash (1+07:08) reboot system boot 2.6.32-696.el6.x Wed Aug 8 09:29 - 05:40 (17+20:10) root pts/2 10.0.0.1 Wed Aug 8 03:38 - crash (05:51) root pts/1 10.0.0.1 Wed Aug 8 03:24 - crash (06:04) root pts/0 10.0.0.1 Wed Aug 8 03:23 - 05:23 (02:00) root tty1 Wed Aug 8 03:23 - crash (06:06) reboot system boot 2.6.32-696.el6.x Mon Aug 6 01:51 - 05:40 (20+03:49) wtmp begins Mon Aug 6 01:51:03 2018
第一列信息:
用户名,或者显示reboot(启动或者重启操作在这里会记录成reboot)
第二列信息:
终端位置,pts/0 (伪终端或虚拟终端) 意味着从诸如SSH或telnet的远程连接的用户。tty (teletypewriter) 意味着直接连接到计算机或者本地连接的用户,如果是启动或者重启操作,这里会显示成system boot
第三列信息:
登录ip或者内核,如果你看见:0.0 或者什么都没有,这意味着用户通过本地终端连接。也有在状态中显示内核版本的信息,笔者猜测这些记录应该是属于系统的操作,如开机,关机,重启等操作
第四列信息:
开始时间,其中的日期格式为date +"%a %b %d"
第五列信息:
结束时间(still login in 还未退出 down 直到正常关机 crash 直到强制关机)
第六列信息:
持续时间