Linux shell last 命令

返回上一级

Linux shell last 命令用于显示系统开机以来获是从每月初登入者的讯息。

使用权限:所有用户。

last 命令语法格式

last [options]

选项

  • -R 省略 hostname 的栏位
  • -num 展示前 num 个
  • username 展示 username 的登入讯息
  • tty 限制登入讯息包含终端机代号

范例

显示当前用户(root) 最新的2个登录信息

[root@localhost ~]# last -R -2
root     pts/0        Thu Sep 21 00:25   still logged in
root     pts/0        Thu Sep 21 00:09 - 00:24  (00:14)

wtmp begins Wed Sep 20 17:18:47 2017
[root@localhost ~]#

一般显示方法

[root@localhost ~]# last
root     pts/0        x.x.x.x    Thu Sep 21 00:25   still logged in
root     pts/0        x.x.x.x    Thu Sep 21 00:09 - 00:24  (00:14)
reboot   system boot  3.10.0-693.el7.x Thu Sep 21 00:04 - 00:29  (00:24)
root     pts/0        x.x.x.x    Wed Sep 20 22:40 - down   (00:19)
root     pts/0        x.x.x.x    Wed Sep 20 22:23 - 22:39  (00:15)
root     pts/2        x.x.x.x    Wed Sep 20 21:32 - 22:22  (00:49)
root     pts/1        x.x.x.x    Wed Sep 20 19:51 - down   (03:07)
root     pts/0        x.x.x.x    Wed Sep 20 18:57 - 21:50  (02:53)
root     tty1                          Wed Sep 20 18:56 - 22:59  (04:02)
reboot   system boot  3.10.0-693.el7.x Wed Sep 20 18:56 - 22:59  (04:02)
root     tty1                          Wed Sep 20 18:53 - 18:55  (00:02)
reboot   system boot  3.10.0-693.el7.x Wed Sep 20 18:52 - 18:55  (00:03)
root     tty1                          Wed Sep 20 18:41 - 18:50  (00:08)
reboot   system boot  3.10.0-693.el7.x Wed Sep 20 18:41 - 18:50  (00:08)
root     tty1                          Wed Sep 20 18:32 - 18:41  (00:09)
reboot   system boot  3.10.0-693.el7.x Wed Sep 20 18:31 - 18:41  (00:10)
root     tty1                          Wed Sep 20 18:24 - 18:27  (00:02)
reboot   system boot  3.10.0-693.el7.x Wed Sep 20 18:24 - 18:41  (00:17)
root     tty1                          Wed Sep 20 18:20 - 18:24  (00:03)
reboot   system boot  3.10.0-693.el7.x Wed Sep 20 18:20 - 18:41  (00:20)
root     tty1                          Wed Sep 20 18:16 - 18:20  (00:04)
reboot   system boot  3.10.0-693.el7.x Wed Sep 20 18:15 - 18:41  (00:25)
root     tty1                          Wed Sep 20 18:00 - 18:15  (00:14)
reboot   system boot  3.10.0-693.el7.x Wed Sep 20 18:00 - 18:15  (00:15)
root     tty1                          Wed Sep 20 17:47 - 18:00  (00:12)
reboot   system boot  3.10.0-693.el7.x Wed Sep 20 17:47 - 18:15  (00:28)
root     tty1                          Wed Sep 20 17:40 - crash  (00:06)
reboot   system boot  3.10.0-693.el7.x Wed Sep 20 17:39 - 18:15  (00:36)
root     tty1                          Wed Sep 20 17:36 - crash  (00:02)
reboot   system boot  3.10.0-693.el7.x Wed Sep 20 17:36 - 18:15  (00:39)
root     tty1                          Wed Sep 20 17:19 - 17:19  (00:00)
reboot   system boot  3.10.0-693.el7.x Wed Sep 20 17:18 - 17:19  (00:01)

简略显示,并指定最近 5 条数据

[root@localhost ~]# last -n 5 -R
root     pts/0        Thu Sep 21 00:25   still logged in
root     pts/0        Thu Sep 21 00:09 - 00:24  (00:14)
reboot   system boot  Thu Sep 21 00:04 - 00:30  (00:25)
root     pts/0        Wed Sep 20 22:40 - down   (00:19)
root     pts/0        Wed Sep 20 22:23 - 22:39  (00:15)

wtmp begins Wed Sep 20 17:18:47 2017

最后一列显示主机IP地址

[root@localhost ~]# last -n 3 -a -i
root     pts/0        Thu Sep 21 00:25   still logged in    x.x.x.x
root     pts/0        Thu Sep 21 00:09 - 00:24  (00:14)     x.x.x.x
reboot   system boot  Thu Sep 21 00:04 - 00:31  (00:26)     0.0.0.0

wtmp begins Wed Sep 20 17:18:47 2017

返回上一级

Linux Shell 命令大全

关于   |   FAQ   |   我们的愿景   |   广告投放   |  博客

  简单教程,简单编程 - IT 入门首选站

Copyright © 2013-2022 简单教程 twle.cn All Rights Reserved.