国产宅男网站在线|亚洲A级性爱免费视频|亚洲中精品级在线|午夜福利AA毛

  • <dd id="gf5jf"><th id="gf5jf"></th></dd>

    <cite id="gf5jf"><label id="gf5jf"></label></cite>
  • <div id="gf5jf"><listing id="gf5jf"></listing></div>
    學(xué)習(xí)啦 > 學(xué)習(xí)電腦 > 操作系統(tǒng) > Linux教程 >

    Linux常用命令last的使用方法是什么

    時(shí)間: 加城1195 分享

      Linux繼承了Unix以網(wǎng)絡(luò)為核心的設(shè)計(jì)思想,是一個(gè)性能穩(wěn)定的多用戶(hù)網(wǎng)絡(luò)操作系統(tǒng)。很多新手用戶(hù)對(duì)last命令可能還不熟悉,下面這篇文章主要給大家介紹了關(guān)于Linux常用命令last的使用方法,需要的朋友可以參考借鑒。

      命令簡(jiǎn)介:

      該命令用來(lái)列出目前與過(guò)去登錄系統(tǒng)的用戶(hù)相關(guān)信息。指令英文原義:show listing of last logged in users

      執(zhí)行權(quán)限 :有些需要特殊權(quán)限

      指令所在路徑:/usr/bin/last

      執(zhí)行l(wèi)ast指令時(shí),它會(huì)讀取位于/var/log目錄下名稱(chēng)為wtmp的文件,并把該給文件的內(nèi)容記錄的登錄系統(tǒng)的用戶(hù)名單全部顯示出來(lái)。默認(rèn)是顯示wtmp的記錄,btmp能顯示的更詳細(xì),可以顯示遠(yuǎn)程登錄,例如ssh登錄。

      utmp文件中保存的是當(dāng)前正在本系統(tǒng)中的用戶(hù)的信息。

      wtmp文件中保存的是登錄過(guò)本系統(tǒng)的用戶(hù)的信息。

      命令輸出字段介紹:

      第一列:用戶(hù)名

      第二列:終端位置。pts/0 (偽終端) 意味著從諸如SSH或telnet的遠(yuǎn)程連接的用戶(hù).tty (teletypewriter) 意味著直接連接到計(jì)算機(jī)或者本地連接的用戶(hù)

      第三列:登錄ip或者內(nèi)核 。如果你看見(jiàn):0.0 或者什么都沒(méi)有,這意味著用戶(hù)通過(guò)本地終端連接。除了重啟活動(dòng),內(nèi)核版本會(huì)顯示在狀態(tài)中。

      第四列:開(kāi)始時(shí)間

      第五列:結(jié)束時(shí)間(still login in 還未退出 down 直到正常關(guān)機(jī) crash 直到強(qiáng)制關(guān)機(jī))

      第六列:持續(xù)時(shí)間

      命令語(yǔ)法:

      last [-R] [-num] [ -n num ] [-adiowx] [ -f file ] [ -t YYYYMMDDHHMMSS ] [name...] [tty...]

      命令參數(shù):

      參數(shù)

      長(zhǎng)參數(shù)

      描敘

      -a

      將登錄系統(tǒng)的的主機(jī)名稱(chēng)或IP地址,顯示在最后一行

      -d

      將IP地址轉(zhuǎn)換成主機(jī)名稱(chēng)

      -f

      指定記錄文件,默認(rèn)是顯示/var/log目錄下的wtmp文件的記錄,但/var/log目錄下得btmp能顯示的內(nèi)容更豐富,可以顯示遠(yuǎn)程登錄,例如ssh登錄 ,包括失敗的登錄請(qǐng)求。

      -i

      -i顯示特定ip登錄的情況。跟蹤用 -i顯示特定ip登錄的情況。跟蹤用

      -o

      Read an old-type wtmp file (written by linux-libc5 applications).

      -n

      -n <顯示行數(shù)>或-<顯示行數(shù)>  設(shè)置顯示多少行記錄

      -w

      Display full user and domain names in the output

      -R

      不顯示登入系統(tǒng)的主機(jī)名稱(chēng)或IP(省略 hostname 的欄位)

      -t

      顯示YYYYMMDDHHMMSS之前的信息

      -x

      顯示系統(tǒng)關(guān)閉、用戶(hù)登錄和退出的歷史

      使用示例:

      1:查看last命令的幫助信息

      [root@DB-Server ~]# man last

      [root@DB-Server ~]# last -h

      last: invalid option -- h

      Usage: last [-num | -n num] [-f file] [-t YYYYMMDDHHMMSS] [-R] [-x] [-o] [-w] [username..] [tty..]

      2:顯示最后登錄系統(tǒng)的N條記錄

      [root@DB-Server ~]#last -10

      root pts/1 :0.0 Wed Dec 18 09:54 still logged in

      root pts/4 :0.0 Wed Dec 18 09:43 - 09:48 (00:04)

      root pts/1 :0.0 Wed Dec 18 09:43 - 09:48 (00:05)

      root pts/3 192.168.103.79 Wed Dec 18 09:41 - 12:40 (02:59)

      root pts/4 :0.0 Wed Dec 18 09:28 - 09:30 (00:01)

      root pts/3 :0.0 Wed Dec 18 09:27 - 09:30 (00:02)

      root pts/2 192.168.103.29 Wed Dec 18 09:27 still logged in

      root pts/1 :0.0 Wed Dec 18 09:27 - 09:42 (00:15)

      root pts/2 :0.0 Wed Dec 18 09:23 - 09:25 (00:01)

      root pts/1 :0.0 Wed Dec 18 09:22 - 09:25 (00:02)

      wtmp begins Wed Dec 11 03:02:17 2013

      [root@DB-Server ~]# last -n 10

      root pts/1 :0.0 Wed Dec 18 09:54 still logged in

      root pts/4 :0.0 Wed Dec 18 09:43 - 09:48 (00:04)

      root pts/1 :0.0 Wed Dec 18 09:43 - 09:48 (00:05)

      root pts/3 192.168.103.79 Wed Dec 18 09:41 - 12:40 (02:59)

      root pts/4 :0.0 Wed Dec 18 09:28 - 09:30 (00:01)

      root pts/3 :0.0 Wed Dec 18 09:27 - 09:30 (00:02)

      root pts/2 192.168.103.29 Wed Dec 18 09:27 still logged in

      root pts/1 :0.0 Wed Dec 18 09:27 - 09:42 (00:15)

      root pts/2 :0.0 Wed Dec 18 09:23 - 09:25 (00:01)

      root pts/1 :0.0 Wed Dec 18 09:22 - 09:25 (00:02)

      wtmp begins Wed Dec 11 03:02:17 2013

      3:將登錄系統(tǒng)的主機(jī)名或IP地址顯示在最后一行

      [root@DB-Server ~]# last -10 -a

      root pts/1 Wed Dec 18 09:54 still logged in :0.0

      root pts/4 Wed Dec 18 09:43 - 09:48 (00:04) :0.0

      root pts/1 Wed Dec 18 09:43 - 09:48 (00:05) :0.0

      root pts/3 Wed Dec 18 09:41 - 12:40 (02:59) 192.168.103.79

      root pts/4 Wed Dec 18 09:28 - 09:30 (00:01) :0.0

      root pts/3 Wed Dec 18 09:27 - 09:30 (00:02) :0.0

      root pts/2 Wed Dec 18 09:27 still logged in 192.168.103.29

      root pts/1 Wed Dec 18 09:27 - 09:42 (00:15) :0.0

      root pts/2 Wed Dec 18 09:23 - 09:25 (00:01) :0.0

      root pts/1 Wed Dec 18 09:22 - 09:25 (00:02) :0.0

      wtmp begins Wed Dec 11 03:02:17 2013

      4:不顯示登入系統(tǒng)的主機(jī)名稱(chēng)或IP地址

      [root@DB-Server ~]# last -10 -R

      root pts/1 Wed Dec 18 09:54 still logged in

      root pts/4 Wed Dec 18 09:43 - 09:48 (00:04)

      root pts/1 Wed Dec 18 09:43 - 09:48 (00:05)

      root pts/3 Wed Dec 18 09:41 - 12:40 (02:59)

      root pts/4 Wed Dec 18 09:28 - 09:30 (00:01)

      root pts/3 Wed Dec 18 09:27 - 09:30 (00:02)

      root pts/2 Wed Dec 18 09:27 still logged in

      root pts/1 Wed Dec 18 09:27 - 09:42 (00:15)

      root pts/2 Wed Dec 18 09:23 - 09:25 (00:01)

      root pts/1 Wed Dec 18 09:22 - 09:25 (00:02)

      wtmp begins Wed Dec 11 03:02:17 2013

      5: 指定/var/log/btmp文件,查看登錄系統(tǒng)的用戶(hù)相關(guān)信息

      [root@DB-Server ~]# last -n 10 -f /var/log/btmp

      root ssh:notty 192.168.136.163 Fri Oct 17 18:16 gone - no logout

      root ssh:notty 192.168.136.163 Fri Oct 17 09:50 - 18:16 (08:26)

      root ssh:notty 192.168.136.163 Fri Oct 17 09:50 - 09:50 (00:00)

      root ssh:notty 192.168.40.218 Tue Jul 23 17:40 - 09:50 (450+16:10)

      root ssh:notty 192.168.236.149 Sun Apr 14 01:34 - 17:40 (100+16:05)

      root ssh:notty 192.168.178.147 Fri Mar 8 17:25 - 01:34 (36+08:08)

      tomcat ssh:notty get185806.gfg1.e Fri Oct 26 16:48 - 17:25 (133+00:37)

      root ssh:notty 192.168.193.3 Mon Oct 22 18:13 - 16:48 (3+22:34)

      root ssh:notty 192.168.193.3 Mon Oct 22 18:13 - 18:13 (00:00)

      devloper ssh:notty get185819.gfg1.e Wed Oct 17 17:22 - 18:13 (5+00:50)

      btmp begins Thu Apr 12 14:30:06 2012

      6: 將IP地址轉(zhuǎn)換成主機(jī)名稱(chēng)

      last -10 -d

      7: 顯示YYYYMMDDHHMMSS(20150110093000)之前的信息

      [root@DB-Server ~]# last -10 -t 20150110093000

      root pts/2 192.168.102.186 Fri Jan 9 15:35 - 17:27 (01:52)

      root pts/2 192.168.102.134 Thu Jan 8 10:25 - 12:27 (02:02)

      root pts/3 192.168.125.53 Tue Jan 6 23:59 - 00:09 (00:09)

      root pts/2 192.168.125.53 Tue Jan 6 23:45 - 00:09 (00:23)

      root pts/3 192.168.102.88 Tue Jan 6 15:23 - 16:20 (00:57)

      root pts/2 192.168.102.88 Tue Jan 6 15:08 - 17:25 (02:16)

      oracle pts/1 :2.0 Tue Jan 6 15:07 still logged in

      reboot system boot 2.6.32-200.13.1. Tue Jan 6 15:07 (7+20:21)

      root pts/2 192.168.102.88 Tue Jan 6 14:47 - down (00:17)

      oracle pts/1 :2.0 Tue Jan 6 14:46 - down (00:18)

      wtmp begins Wed Apr 11 16:31:10 2012

      補(bǔ)充:Linux基本命令

      1.ls命令:

      格式::ls [選項(xiàng)] [目錄或文件]

      功能:對(duì)于目錄,列出該目錄下的所有子目錄與文件;對(duì)于文件,列出文件名以及其他信息。

      常用選項(xiàng):

      -a :列出目錄下的所有文件,包括以 . 開(kāi)頭的隱含文件。

      -d :將目錄像文件一樣顯示,而不是顯示其他文件。

      -i :輸出文件的i節(jié)點(diǎn)的索引信息。

      -k :以k字節(jié)的形式表示文件的大小。

      -l :列出文件的詳細(xì)信息。

      -n :用數(shù)字的UID,GID代替名稱(chēng)。

      -F : 在每個(gè)文件名后面附上一個(gè)字符以說(shuō)明該文件的類(lèi)型,“*”表示可執(zhí)行的普通文 件;“/”表示目錄;“@”表示符號(hào)鏈接;“l”表示FIFOS;“=”表示套接字。

      2.cd命令

      格式:cd [目錄名稱(chēng)]

      常用選項(xiàng):

      cd .. 返回上一級(jí)目錄。

      cd ../.. 將當(dāng)前目錄向上移動(dòng)兩級(jí)。

      cd - 返回最近訪問(wèn)目錄。

      3.pwd命令

      格式: pwd

      功能:顯示出當(dāng)前工作目錄的絕對(duì)路徑。

      相關(guān)閱讀:Linux主要特性

      完全兼容POSIX1.0標(biāo)準(zhǔn)

      這使得可以在Linux下通過(guò)相應(yīng)的模擬器運(yùn)行常見(jiàn)的DOS、Windows的程序。這為用戶(hù)從Windows轉(zhuǎn)到Linux奠定了基礎(chǔ)。許多用戶(hù)在考慮使用Linux時(shí),就想到以前在Windows下常見(jiàn)的程序是否能正常運(yùn)行,這一點(diǎn)就消除了他們的疑慮。

      多用戶(hù)、多任務(wù)

      Linux支持多用戶(hù),各個(gè)用戶(hù)對(duì)于自己的文件設(shè)備有自己特殊的權(quán)利,保證了各用戶(hù)之間互不影響。多任務(wù)則是現(xiàn)在電腦最主要的一個(gè)特點(diǎn),Linux可以使多個(gè)程序同時(shí)并獨(dú)立地運(yùn)行。

      良好的界面

      Linux同時(shí)具有字符界面和圖形界面。在字符界面用戶(hù)可以通過(guò)鍵盤(pán)輸入相應(yīng)的指令來(lái)進(jìn)行操作。它同時(shí)也提供了類(lèi)似Windows圖形界面的X-Window系統(tǒng),用戶(hù)可以使用鼠標(biāo)對(duì)其進(jìn)行操作。在X-Window環(huán)境中就和在Windows中相似,可以說(shuō)是一個(gè)Linux版的Windows。

      支持多種平臺(tái)

      Linux可以運(yùn)行在多種硬件平臺(tái)上,如具有x86、680x0、SPARC、Alpha等處理器的平臺(tái)。此外Linux還是一種嵌入式操作系統(tǒng),可以運(yùn)行在掌上電腦、機(jī)頂盒或游戲機(jī)上。2001年1月份發(fā)布的Linux 2.4版內(nèi)核已經(jīng)能夠完全支持Intel 64位芯片架構(gòu)。同時(shí)Linux也支持多處理器技術(shù)。多個(gè)處理器同時(shí)工作,使系統(tǒng)性能大大提高。


    Linux last的使用方法相關(guān)文章:

    1.linux刪除文件夾命令

    2.kali linux下nmap的使用方法介紹

    3.Linux top命令查看多核CPU每個(gè)核心的使用率

    4.linux系統(tǒng)中tail命令的使用詳解

    5.kali linux下nmap使用方法介紹

    4018967