Examples

1. 列出所有已經開啟的檔案

lsof

2. 列出所有已經開啟的網路, X,25(HP-UX)和UNIX domain檔案

lsof -i -U

3. 列出所有已經開啟的IPv4網路,且是被PID 1234使用的

lsof -i 4 -a -p 1234

4. 只列出IPv6

lsof -i 6

5. 列出所有在主機『wonderland.cc.purdue.edu』上,正在使用ports 513, 514, 515的檔案

lsof -i @wonderland.cc.purdue.edu:513-515

6. 列出在目前domain上mace正在使用的任何檔案(也就是mace.localhost)

lsof -i @mace

7. 列出所有使用者『abe』或是UID『1234』,或者是pid是『456』,『123』,『789』

lsof -p 456,123,789 -u 1234,abe

8. 列出所有在裝置『dev/hd4』中正在使用中的檔案

lsof /dev/hd4

9. 列出誰開啟了檔案『/u/abe/foo』

lsof /u/abe/foo

10. 送『SIGHUP』訊號給給開啟『/u/abe/bar』的程序

kill -HUP 'lsof -t /u/abe/bar'

11. 找出在一個NFS檔案系統上開啟檔案『/nfs/mount/point』的程序,並且其server是不可存取的(並且假設你的mount table已經有提供這個檔案裝置序號了)

lsof -b /nfs/mount/point

12. 使用預先搜尋,並且不輸出warning messages

lsof -bw /nfs/mount/point

13. 忽略裝置快取檔(device cache file)

lsof -Di

14. 取得所有行程的PID,命令名稱(command name field output),和取得所有行程所使用檔案的檔案描述子(file descriptor), 檔案裝置序號(file device number)和檔案inode序號(file inode number)

lsof -FpcfDi

15. 列出所有行程使用者名稱是『abe』,並且執行命令是『lsof』,並且列出檔案描述子(file descriptor)1和3的檔案,每10秒更新一次

lsof -c lsof -a -d 1 -d 3 -u abe -r10

16. 這個例子是關於正規表示法的,列出目前cwd(current working directory)中,所有在正在執行的行程的命令中,第三個字元剛好有『o』或是『O』

lsof -c /^..o.$/i -a -d cwd

17. 藉由一個IP找出相關的IPv4 socket檔

lsof [email protected]

18. 藉由一個IP找出相關的IPv6 socket檔

lsof -i@[0:1:2:3:4:5:6:7]

or

lsof -i@[::1]

19. 循環模式,並且每一次顯示後面都包含了現在時間

lsof -rm====%T====

results matching ""

    No results matching ""