$ netstat -an | grep 127.0.0.1:5432 | awk '{print $6}' | sort | uniq -c結果:
10 CLOSE_WAIT 36 ESTABLISHED 1 LISTEN 33 TIME_WAIT
2. 在top中查看特定的process
$ top -p `pgrep sshd | sed -e :x -e '$!N;s/\n/,/;tx'` # sed 的作用是把換行字元取代成","結果︰
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 2198 root 16 0 90128 3308 2580 S 0.0 0.0 0:02.97 sshd 2212 test 15 0 90228 1880 1104 S 0.0 0.0 0:20.82 sshd 2224 root 16 0 90128 3308 2580 S 0.0 0.0 0:00.03 sshd
3. 監看某一daemon的fd數量
$ watch -n 1 'ls /proc/`pgrep daemon`/fd | wc -l'結果︰
Every 1.0s: ls /proc/`pgrep daemon`/fd | wc -l Mon May 16 21:01:04 2011 50
4. sed取代換行字元
$ sed -e :x -e '$!N;s/\n/,/;tx' 或 $ sed '/^.*$/N;s/,/\n/g'
5. 列出server上的服務
$ netstat -ntulp結果:
Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2304/httpd tcp 0 0 10.32.1.10:22 0.0.0.0:* LISTEN 2110/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2136/sendmail: acce tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 2304/httpd udp 0 0 127.0.0.1:514 0.0.0.0:* 10575/syslog-ng udp 0 0 0.0.0.0:34224 0.0.0.0:* 10614/collectd
6. 查看Linux distribution
$ lsb_release -a or $ cat /etc/issue or $ cat /proc/version
沒有留言:
張貼留言