【Linux】一步一步学Linux——lastlog命令(100)
生活随笔
收集整理的這篇文章主要介紹了
【Linux】一步一步学Linux——lastlog命令(100)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
00. 目錄
文章目錄
- 00. 目錄
- 01. 命令概述
- 02. 命令格式
- 03. 常用選項
- 04. 參考示例
- 05. 附錄
01. 命令概述
lastlog命令用于顯示系統中所有用戶最近一次登錄信息。
lastlog文件在每次有用戶登錄時被查詢。可以使用lastlog命令檢查某特定用戶上次登錄的時間,并格式化輸出上次登錄日志/var/log/lastlog的內容。它根據UID排序顯示登錄名、端口號(tty)和上次登錄時間。如果一個用戶從未登錄過,lastlog顯示**Never logged**。注意需要以root身份運行該命令。
02. 命令格式
用法:lastlog [選項]03. 常用選項
選項:-b, --before DAYS 僅打印早于 DAYS 的最近登錄記錄-C, --clear clear lastlog record of an user (usable only with -u)-h, --help 顯示此幫助信息并推出-R, --root CHROOT_DIR chroot 到的目錄-S, --set set lastlog record to current time (usable only with -u)-t, --time DAYS 僅打印晚于 DAYS 的最近登錄記錄-u, --user LOGIN 打印 LOGIN 用戶的最近登錄記錄04. 參考示例
4.1 顯示系統中所有用戶最近一次登錄信息
[root@itcast ~]# lastlog4.2 顯示指定天數前的登錄信息
[root@itcast ~]# lastlog -b 74.3 顯示指定天數以來的登錄信息
[root@itcast ~]# lastlog -t 7 用戶名 端口 來自 最后登陸時間 root pts/0 六 8月 3 10:27:37 +0800 2019 deng pts/0 172.16.0.51 六 8月 3 10:27:30 +0800 2019 itcast pts/1 三 7月 31 21:25:50 +0800 2019 [root@itcast ~]#4.4 顯示指定用戶的最近登錄信息
[root@itcast ~]# lastlog -u root 用戶名 端口 來自 最后登陸時間 root pts/0 六 8月 3 10:27:37 +0800 2019 [root@itcast ~]#4.5 清除指定用戶的登錄信息
[root@itcast ~]# lastlog -C -u root [root@itcast ~]# [root@itcast ~]# [root@itcast ~]# lastlog -u root 用戶名 端口 來自 最后登陸時間 root **從未登錄過** [root@itcast ~]#05. 附錄
參考:【Linux】一步一步學Linux系列教程匯總
總結
以上是生活随笔為你收集整理的【Linux】一步一步学Linux——lastlog命令(100)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【Linux】一步一步学Linux——l
- 下一篇: 【Linux】一步一步学Linux——u