Linux last 命令用于显示用户最近登录信息。
使用权限:所有使用者。
语法
shell>> last [options]
参数说明:
- -R 省略 hostname 的栏位
- -num 展示前 num 个
- username 展示 username 的登入讯息
- tty 限制登入讯息包含终端机代号
实例
# last -R -2
root pts/0 Fri Sep 25 14:13 still logged in
root pts/0 Wed Sep 23 21:26 - 23:36 (02:09)
wtmp begins Mon Apr 13 19:21:18 2020
# last -2 root
root pts/0 60.12.14.214 Fri Sep 25 14:13 still logged in
root pts/0 183.156.123.189 Wed Sep 23 21:26 - 23:36 (02:09)
wtmp begins Mon Apr 13 19:21:18 2020
一般显示方法
# last
简略显示,并指定显示的个数
# last -n 5 -R
root pts/0 Fri Sep 25 14:13 still logged in
root pts/0 Wed Sep 23 21:26 - 23:36 (02:09)
root pts/0 Mon Sep 21 17:18 - 20:33 (03:15)
root pts/0 Mon Sep 21 14:13 - 16:32 (02:19)
root pts/1 Fri Sep 18 16:23 - 18:16 (01:52)
wtmp begins Mon Apr 13 19:21:18 2020
显示最后一列显示主机IP地址
# last -n 5 -a -i
root pts/0 Fri Sep 25 14:13 still logged in 60.12.14.214
root pts/0 Wed Sep 23 21:26 - 23:36 (02:09) 183.156.123.189
root pts/0 Mon Sep 21 17:18 - 20:33 (03:15) 60.12.14.214
root pts/0 Mon Sep 21 14:13 - 16:32 (02:19) 60.12.14.214
root pts/1 Fri Sep 18 16:23 - 18:16 (01:52) 60.12.14.214
wtmp begins Mon Apr 13 19:21:18 2020