用法如下:
1. 顯示開啓文件abc.txt的進程
lsof abc.txt
lsof -i 22
lsof -c abc
lsof -g gid
lsof +d /usr/local/
lsof +D /usr/local/
lsof -d 4
lsof -n
lsof -p 12
lsof +|-r [t]
-r, lsof會永遠執行,直到被中斷
+r, lsof會一直執行,直到沒可顯示的內容Example:
查看目前ftp連接的情況:lsof -i [email protected]:ftp -r
lsof -s
lsof -u username
語法:lsof -i[46] [protocol][@hostname|hostaddr][:service|port]
46 -- IPV4 or IPV6
protocol -- TCP or UDP
hostname -- Internet host name
hostaddr -- IP地址
service -- /etc/service中的service name(可多選)
port -- 端口號(可多選)
Example:
TCP:25 - TCP and port 25
@1.1.1.1 - IP 1.1.1.1
[email protected] - TCP protocol, ftp service