Linux命令(28)last命令

2022-07-15 08:33:12 字數 1586 閱讀 2512

last命令會讀取位於/var/log/下的wtmp檔案,並把檔案中記錄的使用者相關資訊顯示出來。

用法:last [option]

選項作用

-num

顯示前num個資訊

-r不顯示登入的主機名稱和ip位址

username

顯示指定使用者的登入資訊

示例1:顯示最近登入使用者的資訊

[root@node1 ~]# last

root pts/0 192.168.3.98 tue jun 2 16:49 still logged in

root pts/0 192.168.3.98 tue jun 2 08:22 - 16:49 (08:26)

root pts/8 192.168.3.98 mon jun 1 09:35 - 11:46 (02:11)

root pts/7 192.168.3.98 mon jun 1 09:35 - 11:46 (02:11)

root pts/6 192.168.3.98 mon jun 1 09:35 - 11:46 (02:11)

root pts/5 192.168.3.98 mon jun 1 00:46 - 11:35 (10:48)

root pts/4 192.168.3.98 mon jun 1 00:46 - 11:35 (10:48)

root pts/3 192.168.3.98 mon jun 1 00:46 - 11:35 (10:48)

...

示例2:顯示最近登入系統的5位使用者

[root@node1 ~]# last -5

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:52 (00:-51)

示例3:顯示steven使用者的登入資訊

[root@node1 ~]# last steven

steven pts/1 192.168.3.98 tue jun 2 18:03 still logged in

Linux基礎命令 last

last 顯示以前登入過的使用者資訊,last指令會搜尋 var log wtmp檔案 或者是經過 f選項指定的檔案 然後列出檔案中所有的使用者資訊。如果執行last指令時提示 last var log wtmp no such file or directory 則需要使用指令touch var ...

Linux基礎命令 last

last 顯示以前登入過的使用者資訊,last指令會搜尋 var log wtmp檔案 或者是經過 f選項指定的檔案 然後列出檔案中所有的使用者資訊。如果執行last指令時提示 last var log wtmp no such file or directory 則需要使用指令touch var ...

Linux 命令之last命令詳解

last 命令解釋show listing of last logged in users 指令所在路徑 usr bin last 命令輸出字段介紹 第一列 使用者名稱 第二列 終端位置。pts 0 偽終端 意味著從諸如ssh或telnet的遠端連線的使用者.tty teletypewriter 意...