星期五, 12月 16, 2005

lsof 查看 Unix系統 open file,sockit,IP(草槁)

用途

lsof List Open File
一個列出 Open File工具: File包括 pipes ,IP sockets,directory,devices,inodes

一些範例
lsof
列出所有process的ope file

lsof `which apache2`
lsof /etc/passwd
lsof /dev/hda6
lsof /dev/cdrom
列出 這些open file的process

lsof -t `which apache2`
只列出open file的 PID


lsof -c k
lsof -c bash
lsof -c init
列出 所有 k開頭(bash,init)的open file


lsof -c courier -u ^zahn
列出 所有 courier開頭,但 user不是 zahn 的open file

lsof -u apache,zahn
使用者 apache,zahn所開啟的檔案

lsof +p 30297
PID 30297所開啟的檔案

lsof +D /tmp
開啟 /tmp 目錄 的process

lsof -i
列出開啟的socket
lsof -i :80
列出開啟 80 port 的socket

List all opened Internet and UNIX domain files:

lsof -i -U
列出 所有internet 及UNIX domain 開啟的檔案

lsof -iUDP@www.akadia.com:123
列出從 www.akadia.com 連到UDP 123 port的process


lsof -n
查看所process所開的socket

參考文件
http://www.opensource.apple.com/darwinsource/10.3/lsof-12/lsof/00QUICKSTART

0 Comments:

張貼留言

<< Home