Linux日誌分析常用命令

來源:互聯網
上載者:User

標籤:http   ar   檔案   div   art   log   html   ad   ef   

1.查看檔案內容

cat

-n 顯示行號

2.分頁顯示

more

Enter 顯示下一行

空格 顯示下一頁

F 顯示下一屏

B 顯示上一屏

less

/get 查詢"get"字串並高亮顯示

3.顯示檔案尾

tail

-f 不退出持續顯示

-n 顯示檔案最後n行

4.顯示標頭檔

head

-n 顯示檔案開始n行

5.內容排序

sort

-n 按照數字排序

-r 按照逆序排序

-k 表示排序列

-t 指定分隔字元

6.字元統計

wc

-l 統計檔案中行數

-c 統計檔案位元組數

-L 查看最長行長度

-w 查看檔案包含多少個單詞

7.查看重複出現的行

uniq

-c 查看該行內容出現的次數

-u 只顯示出現一次的行

-d 只顯示重複出現的行

8.字串尋找

grep

9.檔案尋找

find

which

whereis

10.運算式求值

expr

11.歸檔檔案

tar

zip

unzip

12.URL訪問工具

curl

wget

13. 查看請求訪問量

頁面訪問排名前十的IP

cat access.log | cut -f1 -d " " | sort | uniq -c | sort -k 1 -r | head -10

頁面訪問排名前十的URL

cat access.log | cut -f4 -d " " | sort | uniq -c | sort -k 1 -r | head -10

查看最耗時的頁面

cat access.log | sort -k 2 -n -r | head 10

14.大殺器

sed

sed ‘s/xxx/hello‘ access.log 將 xxx 替換成 hello 輸出(s是文本替換命令)

sed -n ‘2,6p‘ access.log 只輸出第第2到第6之間的行(-n表示輸出指定的行)

sed ‘/qq/d‘ access.log 刪除包含qq的行(d是文本刪除命令)

sed ‘=‘ access.log 顯示檔案行號

sed -e ‘i\head‘ access.log 在每行的前面插入head字串(i在行首插入命令)

sed -e ‘a\end‘ access.log 在每行的末尾追加end字串(i在行尾追加命令)

sed -e ‘/google/c\hello‘ access.log 尋找google匹配的行,用hello替換(c是對行文本替換命令)

awk

  • 相關文章推薦:
  • Linux使用者管理命令(useradd、adduser)
  • Linux重啟命令有哪些?linux重啟命令大全
  • linux finger命令用法舉例
  • 本文來自:愛好Linux技術網
  • 本文連結:http://www.ahlinux.com/start/cmd/9070.html

Linux日誌分析常用命令

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.