1、Linux挂載Winodws共享檔案夾
mount -t cifs -o username=name,password=123 //172.16.3.56/d /guaizai
2、檢視http的并發請求數及其TCP連接配接狀态:
netstat -an | awk '/^tcp/{s[$NF]++}END{for (a in s)print a,s[a]}'
3、用tcpdump嗅探80端口的通路看看誰最高
tcpdump -i eth0 -tnn dst port 80 -c 100 | awk -F"." '{print $1"."$2"."$3"."$4}' | sort | uniq -c |
4、檢視目前系統每IP連接配接數
netstat -an | awk -F"[ :]+" '{s[$6]++}END{for (a in s) print s[a],a}' | sort -nr | head
5、shell下32位随機密碼生成
head /dev/urandom | md5sum | head -c 30
6、統計出apache的access.log中通路量最多的5個IP
awk '{s[$1]++}END{for (a in s)print a,s[a]}' access.log | sort -nr
7、找出TMP目錄中已txt結尾!并将重命名為*.sh
#!/bin/bash
str=`find /tmp/ -name \*.txt`
for i in $str
do
mv $i ${i%txt}sh
done
8、檢視ssh惡意連結
cat /var/log/secure | grep "Failed password" | egrep -o "([0-9]{1,3}\.){3}[0-9]" | sort -nr | uniq -c
9、檢視用root登陸失敗的ip
cat /var/log/secure |grep " Failed password for root"| egrep -o "([0-9]{1,3}\.){3}[0-9]"| sort -nr | uniq -
10、通過pid檢視程序路徑
ll /proc/pid
linux指令 — lsof 檢視程序打開那些檔案 或者 檢視檔案給那個程序使用
1.列出所有打開的檔案:
lsof
備注: 如果不加任何參數,就會打開所有被打開的檔案,建議加上一下參數來具體定位
2. 檢視誰正在使用某個檔案
lsof /filepath/file
3.遞歸檢視某個目錄的檔案資訊
lsof +D /filepath/filepath2/
備注: 使用了+D,對應目錄下的所有子目錄和檔案都會被列出
4. 比使用+D選項,周遊檢視某個目錄的所有檔案資訊 的方法
lsof | grep ‘/filepath/filepath2/’
5. 列出某個使用者打開的檔案資訊
lsof -u username
備注: -u 選項,u其實是user的縮寫
6. 列出某個程式所打開的檔案資訊
lsof -c mysql
備注: -c 選項将會列出所有以mysql開頭的程式的檔案,其實你也可以寫成 lsof | grep mysql, 但是第一種方法明顯比第二種方法要少打幾個字元了
7. 列出多個程式多打開的檔案資訊
lsof -c mysql -c apache
8. 列出某個使用者以及某個程式所打開的檔案資訊
lsof -u test -c mysql
9. 列出除了某個使用者外的被打開的檔案資訊
lsof -u ^root
備注:^這個符号在使用者名之前,将會把是root使用者打開的程序不讓顯示
10. 通過某個程序号顯示該進行打開的檔案
lsof -p 1
11. 列出多個程序号對應的檔案資訊
lsof -p 123,456,789
12. 列出除了某個程序号,其他程序号所打開的檔案資訊
lsof -p ^1
13 . 列出所有的網絡連接配接
lsof -i
14. 列出所有tcp 網絡連接配接資訊
lsof -i tcp
15. 列出所有udp網絡連接配接資訊
lsof -i udp
16. 列出誰在使用某個端口
lsof -i :3306
17. 列出誰在使用某個特定的udp端口
lsof -i udp:55
特定的tcp端口
lsof -i tcp:80
18. 列出某個使用者的所有活躍的網絡端口
lsof -a -u test -i
19. 列出所有網絡檔案系統
lsof -N
20.域名socket檔案
lsof -u
21.某個使用者組所打開的檔案資訊
lsof -g 5555
22. 根據檔案描述列出對應的檔案資訊
lsof -d description(like 2)
23. 根據檔案描述範圍列出檔案資訊
lsof -d 2-3