一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

Linux|Centos|Ubuntu|系統(tǒng)進(jìn)程|Fedora|注冊表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

服務(wù)器之家 - 服務(wù)器系統(tǒng) - Linux - Linux常用命令last的使用方法詳解

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

2022-02-12 19:27瀟湘隱者 Linux

最近在學(xué)習(xí)linux命令,學(xué)習(xí)到了last命令,發(fā)現(xiàn)很多同學(xué)對last命令不是很熟悉,last命令的功能列出目前與過去登入系統(tǒng)的用戶相關(guān)信息,下面這篇文章主要給大家介紹了關(guān)于Linux常用命令last的使用方法,需要的朋友可以參考借鑒。

前言

本文主要給大家介紹了關(guān)于linux常用命令last用法的相關(guān)內(nèi)容,分享出來供大家參考學(xué)習(xí),話不多說,來一起看看詳細(xì)的介紹吧。

命令簡介:

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

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

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

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

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

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

命令輸出字段介紹:

   第一列:用戶名

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

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

   第四列:開始時間

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

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

命令語法:

last [-r] [-num] [ -n num ] [-adiowx] [ -f file ] [ -t yyyymmddhhmmss ] [name...]  [tty...]

命令參數(shù):

 

參數(shù)

長參數(shù)

描敘

-a

 

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

-d

 

將ip地址轉(zhuǎn)換成主機名稱

-f

 

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

-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)的主機名稱或ip(省略 hostname 的欄位)

-t

 

顯示yyyymmddhhmmss之前的信息

-x

 

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

 

使用示例:

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

?
1
2
3
4
5
6
7
[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條記錄

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
[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地址顯示在最后一行

?
1
2
3
4
5
6
7
8
9
10
11
12
13
[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地址

?
1
2
3
4
5
6
7
8
9
10
11
12
13
[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)的用戶相關(guān)信息

?
1
2
3
4
5
6
7
8
9
10
11
12
13
[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)換成主機名稱

?
1
last -10 -d

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

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

?
1
2
3
4
5
6
7
8
9
10
11
12
13
[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

總結(jié)

以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作能帶來一定的幫助,如果有疑問大家可以留言交流,謝謝大家對服務(wù)器之家的支持。

原文鏈接:http://www.cnblogs.com/kerrycode/p/4223751.html

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 高h肉厨房 | 99年水嫩漂亮粉嫩在线播放 | 四虎comwww最新地址 | 亚洲第一人黄所 | 国产乱码免费卡1卡二卡3卡四 | 动漫jk美女被爆羞羞漫画 | 美女被躁了在线观看视频 | 国产一区二区免费福利片 | 国产aⅴ一区二区三区 | 欧美一级在线 | 秋霞理论一级在线观看手机版 | 日韩亚洲一区中文字幕在线 | 男人香蕉好大好爽视频 | 日本免费不卡在线一区二区三区 | 日韩欧美在线视频一区二区 | 国内体内she精视频免费 | 91精品天美精东蜜桃传媒免费 | 免费高清www动漫视频播放器 | 成人网中文字幕色 | 蜜桃麻豆 | 岛国虐乳紧缚媚药调教 | 欧美日韩亚洲高清不卡一区二区三区 | 国产一级片在线 | 免费片在线观看 | 女学生被老师调教在教室 | 乖女的嫩奶水h文孕妇 | 日韩一区国产二区欧美三 | 99久久精品免费看国产 | 国产精品合集一区二区 | 乳女教师欲乱动漫无修版动画3d | 青青青在线免费 | 欧美a级v片不卡在线观看 | 九九久久国产精品免费热6 九九精品视频一区二区三区 | 日韩经典在线 | a级情欲片在线观看hd | 亚洲AV无码国产精品午夜久久 | 99精品国产成人一区二区 | 国产白白视频在线观看2 | 天天做天天爱天天爽综合网 | 欧美黑人性猛交╳xx╳动态图 | 男神插曲女生动漫完整版动漫 |