欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Linux常用命令last的使用方法詳解

 更新時間:2017年08月02日 10:07:28   作者:瀟湘隱者  
最近在學習linux命令,學習到了last命令,發(fā)現(xiàn)很多同學對last命令不是很熟悉,last命令的功能列出目前與過去登入系統(tǒng)的用戶相關信息,下面這篇文章主要給大家介紹了關于Linux常用命令last的使用方法,需要的朋友可以參考借鑒。

前言

本文主要給大家介紹了關于Linux常用命令last用法的相關內容,分享出來供大家參考學習,話不多說,來一起看看詳細的介紹吧。

命令簡介:

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

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

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

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

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

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

命令輸出字段介紹:

   第一列:用戶名

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

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

   第四列:開始時間

   第五列:結束時間(still login in 還未退出 down 直到正常關機 crash 直到強制關機)

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

命令語法:

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

命令參數(shù):

參數(shù)

長參數(shù)

描敘

-a

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

-d

將IP地址轉換成主機名稱

-f

指定記錄文件,默認是顯示/var/log目錄下的wtmp文件的記錄,但/var/log目錄下得btmp能顯示的內容更豐富,可以顯示遠程登錄,例如ssh登錄 ,包括失敗的登錄請求。

-i

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

-o

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

-n

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

-w

Display full user and domain names in the output

-R

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

-t

顯示YYYYMMDDHHMMSS之前的信息

-x

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

使用示例:

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)的主機名或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)的主機名稱或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)的用戶相關信息

[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地址轉換成主機名稱

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

總結

以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作能帶來一定的幫助,如果有疑問大家可以留言交流,謝謝大家對腳本之家的支持。

相關文章

  • Apache偽靜態(tài)Rewrite詳解

    Apache偽靜態(tài)Rewrite詳解

    這篇文章主要介紹了Apache偽靜態(tài)Rewrite的相關知識以及使用方法和使用實例,需要的朋友可以參考下
    2014-03-03
  • Linux磁盤空間釋放問題整理

    Linux磁盤空間釋放問題整理

    在本篇文章里小編給大家分享了一篇關于Linux磁盤空間釋放問題整理內容,有需要的朋友們可以學習參考下。
    2020-12-12
  • CentOS7 + node.js + nginx + MySQL搭建服務器全過程

    CentOS7 + node.js + nginx + MySQL搭建服務器全過程

    這篇文章主要介紹了關于CentOS7 + node.js + nginx + MySQL搭建服務器的全過程,文章通過一步步的步驟進行介紹的很詳細,相信對大家具有一定的參考價值,需要的朋友們下面來一起看看吧。
    2017-03-03
  • Cpanel下Cron Jobs定時執(zhí)行PHP的方法

    Cpanel下Cron Jobs定時執(zhí)行PHP的方法

    PHP代碼需要定時執(zhí)行,如果你有Linux或unix系統(tǒng)權限或網(wǎng)站使用的是Cpanel后臺,那么可以使用Cron JOBS來完成PHP的定時執(zhí)行功能。飄易簡單介紹一下cpanel下的使用方法
    2021-07-07
  • Linux命令學習總結之rm命令

    Linux命令學習總結之rm命令

    rm命令用來刪除Linux系統(tǒng)中的文件或目錄。通常情況下rm不會刪除目錄,你必須通過指定參數(shù)-r或-R來刪除目錄。接下來通過本文給大家分享Linux命令學習總結之rm命令,對linux rm命令相關知識感興趣的朋友一起學習吧
    2016-01-01
  • linux負載均衡總結性說明 四層負載和七層負載有什么區(qū)別

    linux負載均衡總結性說明 四層負載和七層負載有什么區(qū)別

    這篇文章主要為大家詳細介紹了linux負載均衡的相關資料,什么是負載均衡?四層負載和七層負載有什么區(qū)別?具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-04-04
  • Vim的分屏功能命令大全

    Vim的分屏功能命令大全

    寫code的朋友可能都會有個煩惱,長長的代碼,小小的屏幕,是我怎能瞻前顧后?而vim的分屏功能在一定程度上解決了這個問題。這篇文章主要給大家介紹了Vim的分屏功能實現(xiàn),文中通過圖文以及詳細步驟給大家進行了介紹,相信會對大家的理解和學習很有幫助,
    2016-11-11
  • Linux查看History記錄加時間戳的小技巧

    Linux查看History記錄加時間戳的小技巧

    今天小編就為大家分享一篇關于Linux查看History記錄加時間戳的小技巧,小編覺得內容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧
    2019-02-02
  • Centos7.2 編譯安裝方式搭建 phpMyAdmin

    Centos7.2 編譯安裝方式搭建 phpMyAdmin

    這篇文章主要介紹了Centos7.2 編譯安裝方式搭建 phpMyAdmin ,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-08-08
  • ubuntu 16.04LTS 開機啟動自動更換壁紙的實現(xiàn)方法

    ubuntu 16.04LTS 開機啟動自動更換壁紙的實現(xiàn)方法

    下面小編就為大家分享一篇ubuntu 16.04LTS 開機啟動自動更換壁紙的實現(xiàn)方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-02-02

最新評論