linux命令——last查看登录关机记录

last作用是显示近期用户或终端的登录情况,通过last命令查看该程序的log,管理员可以获知谁曾经或者企图连接系统。

1、查看重启记录

last reboot命令

复制代码
[root@test ~]# last reboot
reboot system boot 2.6.32-431.el6.x Mon May 21 16:32 - 15:06 (1+22:33)
reboot system boot 2.6.32-431.el6.x Wed May 16 18:40 - 15:06 (6+20:25)
reboot system boot 2.6.32-431.el6.x Wed May 2 16:44 - 15:06 (20+22:22)
reboot system boot 2.6.32-431.el6.x Fri Mar 2 18:47 - 15:06 (81+20:18)
reboot system boot 2.6.32-431.el6.x Sun Feb 11 17:56 - 15:06 (100+21:09)
reboot system boot 2.6.32-431.el6.x Fri Dec 22 18:24 - 15:06 (151+20:41)
复制代码

2、查看用户登录记录

[root@hch ~]# last -a
root pts/1 Mon May 21 16:29 still logged in 10.x.x.x
root pts/0 Mon May 21 08:36 still logged in 10.x.x.x
reboot system boot Mon May 21 16:32 - 15:07 (1+22:34) 2.6.32-431.el6.x86_64
root pts/1 Thu May 17 14:06 - crash (4+02:26) 10.x.x.x
root pts/0 Wed May 16 10:50 - crash (5+05:42) 10.x.x.x

参数说明
-a 把从何处登入系统的主机名称或IP地址,显示在最后一行。
-d 将IP地址转换成主机名称。
-f 指定记录文件。
-n 或- 设置列出名单的显示列数。
-R 不显示登入系统的主机名称或IP地址。
-x 显示系统关机,重新开机,以及执行等级的改变等信息

原文地址:https://www.cnblogs.com/gezp/p/14245721.html