Molet

Linux last命令:显示用户或终端的登录情况

Molet linux 2023-01-24 458浏览 0

Linux last 命令用于显示用户最近登录信息。

语法格式:last [选项]

常用参数:

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

参考实例

显示近期用户或终端的登录情况:

[root@bunian ~]# last
root     pts/0        127.0.0.1        Thu Dec 23 10:17   still logged in   
root     pts/0        127.0.0.1        Wed Dec 22 10:59 - 18:13  (07:14)    
root     pts/0        115.63.64.90     Sun Dec 19 19:02 - 01:52  (06:49)    
root     pts/0        115.63.64.90     Sun Dec 19 11:01 - 18:50  (07:49)    
root     pts/0        115.63.69.129    Sat Dec 18 11:26 - 22:23  (10:56)    
root     pts/0        115.63.69.129    Fri Dec 17 09:55 - 02:30  (16:35)    
root     pts/0        115.63.70.196    Thu Dec 16 19:15 - 22:47  (03:32)    
root     pts/0        127.0.0.1        Thu Dec 16 13:22 - 13:40  (00:17)    
root     pts/0        127.0.0.1        Thu Dec 16 13:22 - 13:22  (00:00)    
lighthou pts/0        119.28.22.215    Wed Dec  1 12:30 - 12:41  (00:10)    
reboot   system boot  3.10.0-1160.31.1 Wed Dec  1 12:30 - 10:27 (21+21:56)  

简略显示,并指定显示的个数:

[root@bunian ~]# last -n 5 -R
root     pts/0        Thu Dec 23 10:17   still logged in   
root     pts/0        Wed Dec 22 10:59 - 18:13  (07:14)    
root     pts/0        Sun Dec 19 19:02 - 01:52  (06:49)    
root     pts/0        Sun Dec 19 11:01 - 18:50  (07:49)    
root     pts/0        Sat Dec 18 11:26 - 22:23  (10:56)    

显示最后一列显示主机IP地址:

[root@bunian ~]# last -n 5 -a -i
root     pts/0        Thu Dec 23 10:17   still logged in    127.0.0.1
root     pts/0        Wed Dec 22 10:59 - 18:13  (07:14)     127.0.0.1
root     pts/0        Sun Dec 19 19:02 - 01:52  (06:49)     115.63.64.90
root     pts/0        Sun Dec 19 11:01 - 18:50  (07:49)     115.63.64.90
root     pts/0        Sat Dec 18 11:26 - 22:23  (10:56)     115.63.69.129

继续浏览有关 Linux命令 的文章
发表评论