資源描述:
《Linux日志系統(tǒng)》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫。
1、一、Linux系統(tǒng)日志作用 日志對任何一個OS、應(yīng)用軟件、服務(wù)進程而言都是必不可少的模塊。日志文件對于系統(tǒng)和網(wǎng)絡(luò)安全起到中大作用,同時具有審計、跟蹤、排錯功能??梢酝ㄟ^日志文件監(jiān)測系統(tǒng)與網(wǎng)絡(luò)安全隱患,以及監(jiān)測黑客入侵攻擊路線。二、日志分類 1.連接時間的日志 連接時間日志一般由/var/log/wtmp和/var/run/utmp(有關(guān)當(dāng)前登錄用戶的信息記錄在文件utmp中;登錄進入和退出記錄在文件wtmp中;數(shù)據(jù)交換、關(guān)機以及重啟的機器信息也都記錄在wtmp文件中。)這兩個文件記錄,不過這兩個文件無法直
2、接cat查看,并且該文件由系統(tǒng)自動更新,可以通過如下:w/who/finger/id/last/lastlog/ac?進行查看 [root@51cto~]#who root????tty1????????2010-10-0622:56 root????pts/0???????2010-10-0622:26(218.192.87.4) root????pts/1???????2010-10-0623:41(218.192.87.4) root????pts/3???????2010-10-0623:18
3、(218.192.87.4) [root@51cto~]#w 01:01:02up?2:36,?4users,?loadaverage:0.15,0.03,0.01 USER????TTY?????FROM?????????????LOGIN@??IDLE??JCPU??PCPUWHAT root????tty1????-????????22:56???1:20m?0.16s?0.16s-bash root????pts/0???218.192.87.4????22:26???2:05m?0.18s?
4、0.18s-bash root????pts/1???218.192.87.4????23:41???0.00s????0.41s?0.00sw root????pts/3???218.192.87.4????23:18???1:38m?0.03s?0.03s-bash [root@51cto~]#?ac-p???//查看每個用戶的連接時間 u51?????????????????????????????????1.23 u55?????????????????????????????????0.04
5、 root???????????????????????????????95.21???//可以看到root連接時間最長吧 51cto???????????????????????????????0.06 user1???????????????????????????????3.93 total?????100.48 [root@51cto~]#ac-a????//查看所有用戶的連接時間 total?????100.49 [root@51cto~]#ac-d????//查看用戶每天的連接時間
6、Sep24?total???????0.14 Sep25?total??????14.60 Sep26?total??????13.71 Sep27?total??????21.47 Sep28?total??????11.74 Sep29?total???????6.60 Sep30?total???????8.81 Oct?1??total???????9.04 Oct?2??total???????0.47??????//可以看到我國慶3、4、5號出去玩了 Oct?6??total???
7、????8.62 Today??total???????5.29 其他幾個命令不做具體介紹了 2.進程監(jiān)控日志 進程統(tǒng)計監(jiān)控日志在監(jiān)控用戶的操作指令是非常有效的。當(dāng)服務(wù)器最近發(fā)現(xiàn)經(jīng)常無故關(guān)機或者無故被人刪除文件等現(xiàn)象時,可以通過使用進程統(tǒng)計日志查看: [root@51cto~]#accton/var/account/pacct?????//開啟進程統(tǒng)計日志監(jiān)控 [root@51cto~]#lastcomm????//查看進程統(tǒng)計日志情況 accton???????????S????root????
8、pts/1?????0.00secsThuOct?701:20 accton?????????root????pts/1?????0.00secsThuOct?701:20 ac???????????root????pts/1?????0.00secsThuOct?701:14 ac???????????root????pts/1?????0.00secsThuOct?701:1