2020-05-26

Linux命令(28)last命令

Linux命令(28)last命令


last命令

  • 功能说明:显示最近登录用户的列表

    last命令会读取位于/var/log/下的wtmp文件,并把文件中记录的登录系统的用户名显示出来。

  • 用法:last

    选项作用
    -n设置显示名单的行数
    -R不显示登录的主机名称和IP地址

    示例:显示最近登录用户的信息

    root  pts/1  192.168.3.98  Mon May 25 18:57 still logged in root  pts/0  192.168.3.98  Mon May 25 17:21 - 21:01 (03:40) root  pts/0  192.168.3.98  Mon May 25 15:44 - 17:21 (01:36) root  tty1       Mon May 25 15:44 still logged in reboot system boot 3.10.0-957.el7.x Mon May 25 23:44 - 22:50 (00:-53) root  pts/1  192.168.3.98  Tue Jan 22 23:33 - crash (24961+00:11root  pts/0  192.168.3.98  Tue Jan 22 22:57 - crash (24961+00:46root  pts/2  192.168.3.98  Tue Jan 22 17:34 - 19:55 (02:20) root  pts/0  192.168.3.98  Wed Feb 21 00:13 - 19:43 (-24136+-4:-root  tty6       Wed Feb 21 00:12 - 23:33 (-24136+00:-root  pts/1  192.168.3.98  Mon May 11 11:17 - 19:13 (-24946+-16:root  pts/0  192.168.3.98  Sun May 10 10:06 - 12:33 (1+02:26) root  tty5       Sun May 10 09:52 - 23:33 (-24945+-10:root  tty4       Sun May 10 09:52 - 23:33 (-24945+-10:root  tty3       Sun May 10 09:52 - 23:33 (-24945+-10:root  tty2       Sun May 10 09:52 - 23:33 (-24945+-10:root  tty6       Sun May 10 09:51 - 11:16 (1+01:25) root  pts/0  192.168.3.98  Sun May 10 08:42 - 10:06 (01:24) root  tty1       Sun May 10 08:41 - 23:33 (-24945+-9:-reboot system boot 3.10.0-957.el7.x Sun May 10 08:36 - 22:50 (15+14:13) 

    示例2:显示最近登录系统的5位用户

    [root@node1 ~]# last -n 5root  pts/1  192.168.3.98  Mon May 25 18:57 still logged in root  pts/0  192.168.3.98  Mon May 25 17:21 - 21:01 (03:40) root  pts/0  192.168.3.98  Mon May 25 15:44 - 17:21 (01:36) root  tty1       Mon May 25 15:44 still logged in reboot system boot 3.10.0-957.el7.x Mon May 25 23:44 - 22:52 (00:-51) 

No comments:

Post a Comment