2019-03-15 14:13:25 2270瀏覽
對(duì)Linux開發(fā)技術(shù)感興趣的小伙伴應(yīng)該或多或少都知道一些Linux last命令,Linux last命令用于顯示系統(tǒng)開機(jī)以來獲是從每月初登入者的訊息,文篇文章扣丁學(xué)堂Linux培訓(xùn)小編就和讀者們分享一下Linux基礎(chǔ)命令last命令,感興趣的朋友就隨小編一起來了解一下吧。
last:
顯示以前登錄過的用戶信息,last指令會(huì)搜索/var/log/wtmp文件(或者是經(jīng)過-f選項(xiàng)指定的文件),然后列出文件中所有的用戶信息。如果執(zhí)行l(wèi)ast指令時(shí)提示“l(fā)ast /var/log/wtmp∶ NO such file or directory”,則需要使用指令touch /var/log/wtmp手工創(chuàng)建此文件。
lastb指令用來顯示登錄失敗的用戶信息,其用法和last一樣,對(duì)應(yīng)的日志文件是/var/log/btmp。
此命令的適用范圍:RedHat、RHEL、Ubuntu、CentOS、SUSE、openSUSE、Fedora。
1、語法
last [-R] [-num] [ -n num ] [-adFiowx] [ -f file ] [ -t YYYYMMDDHHMMSS ] [name...] [tty...] lastb [-R] [-num] [ -n num ] [ -f file ] [-adFiowx] [name...] [tty...]
2、選項(xiàng)列表
3、實(shí)例
1)顯示最近登錄的5條信息
[root@localhost ~]# last -5 //也可以使用last –n 5 //登錄用戶 登錄終端 主機(jī)名 登錄時(shí)間 注銷時(shí)間 持續(xù)時(shí)間 root pts/0 :0.0 Tue Sep 4 13:10 still logged in root pts/0 :0.0 Wed Aug 22 15:07 - 13:09 (12+22:02) root pts/1 :0.0 Wed Aug 22 07:46 - 13:10 (13+05:23) root pts/0 :0.0 Wed Aug 22 07:43 - 11:02 (03:18) root tty1 :0 Wed Aug 22 07:20 still logged in wtmp begins Wed Aug 8 18:02:52 2018
2)顯示用戶weijie和root在8月9號(hào)的登錄信息
[root@localhost ~]# last -t 20180809090000 weijie //可以看到用戶weijie在8.9之前沒有登錄 wtmp begins Wed Aug 8 18:02:52 2018 [root@localhost ~]# last -t 20180809090000 root //用戶root在8.9之前登錄過幾次 root pts/0 :0.0 Wed Aug 8 20:19 - down (00:05) root tty1 :0 Wed Aug 8 20:19 - down (00:06) root pts/1 :0.0 Wed Aug 8 18:16 - 20:16 (01:59) root pts/0 :0.0 Wed Aug 8 18:08 - 20:15 (02:06) root tty1 :0 Wed Aug 8 18:04 - 20:16 (02:11) wtmp begins Wed Aug 8 18:02:52 2018
3)顯示終端tty1的登錄信息
[root@localhost ~]# last 1 //等同于last tty1 root tty1 :0 Wed Aug 22 07:20 still logged in root tty1 :0 Tue Aug 21 17:34 - down (02:24) … wtmp begins Wed Aug 8 18:02:52 2018
想要了解更多關(guān)于Linux開發(fā)方面內(nèi)容的小伙伴,請(qǐng)關(guān)注扣丁學(xué)堂Linux培訓(xùn)官網(wǎng)、微信等平臺(tái),扣丁學(xué)堂IT職業(yè)在線學(xué)習(xí)教育有專業(yè)的Linux講師為您指導(dǎo),此外扣丁學(xué)堂老師精心推出的Linux視頻教程定能讓你快速掌握Linux從入門到精通開發(fā)實(shí)戰(zhàn)技能??鄱W(xué)堂Linux技術(shù)交流群:422345477。
【關(guān)注微信公眾號(hào)獲取更多學(xué)習(xí)資料】
查看更多關(guān)于“Linux培訓(xùn)資訊”的相關(guān)文章>>