1. 程式人生 > >lsof 常用命令總結

lsof 常用命令總結

列出所有開啟的檔案

lsof | grep -i deleted

遞迴檢視某個目錄的檔案資訊

lsof +D /data/mysql/ | grep xxx

檢視誰正在使用某個檔案

lsof /data/mysql57/data/mysql/db.MYD

列出某個使用者開啟的檔案資訊

lsof -u mysql

列出某個程式所開啟的檔案資訊

lsof -c mysql 等價於 lsof | grep mysql

列出除了某個使用者外的被開啟的檔案資訊

lsof -u ^root

通過某個程序號顯示該進行開啟的檔案

lsof -p 109652,109652

列出除了某個程序號,其他程序號所開啟的檔案資訊

lsof -p ^1

列出所有的網路連線

lsof -i

列出所有tcp 網路連線資訊

lsof -i tcp

列出所有udp網路連線資訊

lsof -i udp

列出誰在使用某個埠

lsof -i :3306

列出誰在使用某個特定的udp埠

lsof -i udp:55

特定的tcp埠

lsof -i tcp:80

列出某個使用者的所有活躍的網路埠

lsof -i tcp -u mysql -a

根據檔案描述範圍列出檔案資訊

lsof -d 2-3

參考:https://www.cnblogs.com/chenjinxi/p/8268324.html