1,在dir目錄中查找file文件: find dir -name file
2,在dir目錄中搜索含有str字符串的文件: grep -R str dir
3,其他常用的工具:過濾 grep,用指定分隔符取某個字段值 awk,刪除替換字符串 sed
4,遠程獲取文件/文件夾(-r):scp -P 22345 [email protected]:/dir1/file /dir2
5,遠程上傳文件/文件夾(-r):scp -P 22345 ./file [email protected]:/dir1 (注:-P 指定端口)
6,查看appname的進程ID情況:ps aux | grep "appname" 然後殺死該進程:kill -9 PID (注:若涉硬件層調用,可能卡死)
7,查看系統cpu實時佔用情況:mpstat -P ALL 1 cpu詳細信息 cat /proc/cpuinfo
8,查看系統內存使用情況:free 詳細點的: cat /proc/meminfo
9,獲取系統識別的磁盤:fdisk -l 查看各分區的掛在目錄及剩餘容量:df -h
10,掛在某個分區到某個目錄節點:mount /dev/sdb1 ./sf-u 驗證 df -h 卸載 umount /dev/sdb1或者 umount ./sf-u
11,測試ip聯通性: ping ip ,(icmp)提示"主機不可達",去的路上掛了! ;提示"超時",來的路上掛了!(找不到回去的路由)
12,查看ip經過的路由節點:win7,tracert ip linux,traceroute ip
13,查看ip對應的mac地址:arp -a 設置靜態的 ip-mac 對: arp -s ip (解決arp攻擊的方法之一)
14,抓指定網口的ping(icmp)包: tcpdump -i eth0 icmp
15,抓指定ip的arp廣播包:tcpdump -i eth0 arp | grep "200\.200\.155\.154"
16,抓指定ip/port的數據包:tcpdump -i eth0 host 200.200.155.154 and port not 47191 -n -c 1000
17,抓包到文件,方便wareshark分析:tcpdump -i eth0 host 200.200.155.154 and port not 47191 -n -c 1000 -nnv -s0 -w ./sf.cap
18,爲指定網口添加ip地址:ip addr add 192.168.5.19/24 dev eth0
19,查看路由:ip route 然後添加靜態路由:ip route add 200.200.0.0/16 via 200.200.91.254
20,網口的一些操作及信息查看:ethtool -i/p/d/S eth0,ethtool eth0,ifconfig eth0,ifconfig down/up eth0
21,調試shell腳本:bash -x ./test.sh
暫時能想到的就這麼多,後續的常用linux命令有待補充...
plus,測試網絡被我搞環路了好幾天,今天測試同事終於查明原因,通知我說,是我的設備搞得鬼。剛開始我還死不承認,後來用網線直連打開ESXI,看到其中一個系統的兩個網口,分明配置了"透明口",這是誰配置的? 我想一定是某個新同事搞得,爲了證實這點,特地看了下操作日誌,無奈環路的這段時間就是我的ip在登入。。。有時候自己不經意做的事,等注意到這是自己做的,往往會大吃一驚。呵呵,50 rmb 作爲懲罰。。。
網癱禍首:交換機網口短接,虛擬機網口配置透明,arp代理。