Linux Common Debug commands

Source: Internet
Author: User

1. View TCP connection Status

netstat -nat |awk  ' {print $6} ' |sort|uniq -c|sort -rn netstat -n  | awk  '/^tcp/ {++s[$NF]}; End {for (A in s)  print a, s[a]} ' netstat -n | awk  '/^tcp/  {++state[$NF]}; end {for (key in state)  print key, "\ T", State[key]} ' netstat  -n | awk  '/^tcp/ {++arr[$NF]}; End {for (K in arr)  print k, "\ T", arr[k]} ' netstat -n |awk  '/^tcp/ { print  $NF} ' |sort|uniq -c|sort -rn netstat -ant | awk  ' {print  $NF} '  | grep -v  ' [A-z] '  | sort | uniq -c 
netstat -nat |awk  ' {print $6} ' |sort|uniq -c|sort -rn netstat -n  | awk  '/^tcp/ {++s[$NF]}; End {for (A in s)  print a, s[a]} ' netstat -n | awk  '/^tcp/  {++state[$NF]}; end {for (key in state)  print key, "\ T", State[key]} ' netstat  -n | awk  '/^tcp/ {++arr[$NF]}; End {for (K in arr)  print k, "\ T", arr[k]} ' netstat -n |awk  '/^tcp/ { print  $NF} ' |sort|uniq -c|sort -rn netstat -ant | awk  ' {print  $NF} '  | grep -v  ' [A-z] '  | sort | uniq -c 


2. Find up to 20 IP connections for request 80 ports

Netstat-anlp|grep 80|grep Tcp|awk ' {print $} ' |awk-f: ' {print '} ' |sort|uniq-c|sort-nr|head-n20netstat-ant |awk '/:8 0/{split ($5,ip, ":"); ++a[ip[1]]}end{for (i in A) print A,i} ' |sort-rn|head-n20
Tcpdump-i ETH0-TNN DST Port 80-c 1000 | Awk-f "." ' {print $ '. $ "." $ "." $4} ' | Sort | uniq-c | SORT-NR |head-n 20


3. Find more Time_wait connections

Netstat-n|grep Time_wait|awk ' {print $} ' |sort|uniq-c|sort-rn|head-n20


4, look for more SYN connections

Netstat-an | grep SYN | awk ' {print $} ' | Awk-f: ' {print $} ' | Sort | uniq-c | Sort-nr | More


5, according to the port column process

NETSTAT-NTLP | grep 80 | awk ' {print $7} ' | Cut-d/-F1


6. Get the first 10-bit IP address for Web Access

Cat Access.log|awk ' {print $} ' |sort|uniq-c|sort-nr|head-n 10cat Access.log|awk ' {counts[$ (11)]+=1}; END {for (URL in counts) print Counts[url], url} '


7. Most visited files or pages, take the top 20

Cat Access.log|awk ' {print $11} ' |sort|uniq-c|sort-nr|head-n 20


8. List the maximum number of RAR files transmitted

Cat Access.log|awk ' {print $11} ' |sort|uniq-c|sort-nr|head-n 20


9. list rar files with output greater than 200000byte (approx. 200kb) and the number of corresponding file occurrences

Cat Access.log |awk ' ($ > 200000 && $7~/\.rar/) {print $7} ' |sort-n|uniq-c|sort-nr|head-n 100


10. If the last column of the log records the paging file transfer time, there are the most time-consuming pages listed to the client

Cat Access.log |awk ' ($7~/\.php/) {print $NF "" $ "" $4 "" $7} ' |sort-nr|head-n 100cat access.log |awk ' ($7~/\.php/) {p Rint $NF "" $ "" $4 "" $7} ' |sort-nr|head-n 100


11. List the most time-consuming pages (more than 60 seconds) and the number of corresponding page occurrences

Cat Access.log |awk ' ($NF > && $7~/\.php/) {print $7} ' |sort-n|uniq-c|sort-nr|head-n 100


12. List files with transmission time exceeding 30 seconds

Cat Access.log |awk ' ($NF >) {print $7} ' |sort-n|uniq-c|sort-nr|head-n 20


13, Statistics website Traffic (G)

Cat Access.log |awk ' {sum+=$10} END {print sum/1024/1024/1024} '


14, the connection of statistics 404

awk ' ($9 ~/404/) ' Access.log | awk ' {print $9,$7} ' | Sort


15. Statistics HTTP Status

Cat Access.log |awk ' {counts[$ (9)]+=1}; END {for (code in counts) print code, Counts[code]} ' cat Access.log |awk ' {print $9} ' |sort|uniq-c|sort-rn


16. See which crawlers are crawling content

Tcpdump-i Eth0-l-S 0-w-DST Port 80 | Strings | Grep-i User-agent | Grep-i-E ' bot|crawler|slurp|spider '


17. View SQL statements executed by the database

Tcpdump-i eth0-s 0-l-w-dst Port 3306 | Strings | Egrep-i ' select| update| delete| Insert| Set| Commit| rollback| create| drop| alter| Call '


18. Statistic Traffic by domain

Zcat squid_access.log.tar.gz| awk ' {print $10,$7} ' |awk ' begin{fs= "[/]"}{trfc[$4]+=$1}end{for (domain in TRFC) {printf "%s\t%d\n", Domain,trfc[domain] }}‘


19. Debug command

Strace-p PID


20. Disk Performance

Iostat-x 1 10

Geek Small a original

This article is from the "System World" blog, please be sure to keep this source http://sgk2011.blog.51cto.com/1551358/1825303

Linux Common Debug commands

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.