欢迎您 本站地址:  

Linux last 命令

Linux 命令大全 Linux 命令大全

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

单独执行 last 指令,它会读取位于 /var/log/目录下,名称为 wtmp 的文件,并把该文件记录登录的用户名,全部显示出来。

语法

last [options] [username...] [tty...]

参数说明

options:

username:

tty:

实例

显示两行,并省略主机名 hostname 的列:

# last -R -2
root     pts/0        Thu Apr 28 18:06   still logged in
root     pts/0        Tue Apr 26 09:06 - 19:36  (10:30)

wtmp begins Sun Apr  3 13:11:25 2022

显示两行,并省略主机列:

~# last -R -2
root     pts/0        Thu Apr 28 18:06   still logged in
root     pts/0        Tue Apr 26 09:06 - 19:36  (10:30)

wtmp begins Sun Apr  3 13:11:25 2022

一般显示方法:

# last
...
root   pts/4    Thu May 13 17:25  still logged in  
root   pts/2    Thu May 13 17:23 - 17:25 (00:02)  
root   pts/1    Thu May 13 16:46  still logged in  
...

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

# last -n 5 -R
root   pts/4    Thu May 13 17:25  still logged in  
root   pts/2    Thu May 13 17:23 - 17:25 (00:02)  
root   pts/1    Thu May 13 16:46  still logged in  
root   pts/7    Thu May 13 15:36  still logged in  
root   pts/9    Thu May 13 15:35  still logged in  

wtmp begins Thu May 13 18:55:40 2014

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

# last -n 5 -a -i
root   pts/4    Thu May 13 17:25  still logged in  192.168.1.10
root   pts/2    Thu May 13 17:23 - 17:25 (00:02)   192.168.1.10
root   pts/1    Thu May 13 16:46  still logged in  192.168.1.10
root   pts/7    Thu May 13 15:36  still logged in  192.168.1.10
root   pts/9    Thu May 13 15:35  still logged in  192.168.1.10

wtmp begins Thu May 13 18:55:40 2014

Linux 命令大全 Linux 命令大全

小库提示

扫描下方二维码,访问手机版。