82 7 lsof 高階用法

2021-09-22 17:38:04 字數 1511 閱讀 5460

組合引數

# lsof -a -c bash -u root

command pid user fd type device size/off node name

bash 1394 root cwd dir 8,2 4096 4849665 /root

bash 1394 root rtd dir 8,2 4096 2 /

bash 1394 root txt reg 8,2 938768 3671557 /bin/bash

bash 1394 root mem reg 8,2 156872 3014902 /lib64/ld-2.12.so

bash 1394 root mem reg 8,2 1922152 3014903 /lib64/libc-2.12.so

bash 1394 root mem reg 8,2 22536 3014911 /lib64/libdl-2.12.so

bash 1394 root mem reg 8,2 138280 3018719 /lib64/libtinfo.so.5.7

bash 1394 root mem reg 8,2 65928 3017998 /lib64/libnss_files-2.12.so

bash 1394 root mem reg 8,2 26060 2632051 /usr/lib64/gconv/gconv-modules.cache

bash 1394 root mem reg 8,2 99158576 2648204 /usr/lib/locale/locale-archive

bash 1394 root 0u chr 136,7 0t0 10 /dev/pts/7

bash 1394 root 1u chr 136,7 0t0 10 /dev/pts/7

bash 1394 root 2u chr 136,7 0t0 10 /dev/pts/7

bash 1394 root 255u chr 136,7 0t0 10 /dev/pts/7

每個5秒重新整理一次

# lsof -c init -a -r5
列出www使用者的所有活躍的網路埠

[root@netkiller ~]# lsof -a -u www -i

列出被sshd程序所開啟的所有ipv4網路相關檔案

[root@netkiller ~]# lsof -i 4 -c sshd -a

列出被root使用者所開啟的所有tcp和ipv4網路相關檔案

[root@netkiller ~]# lsof -i 4 -i tcp -u root -a

Lsof命令及用法

lsof options filename 如果提示沒有安裝lsof這個命令,centos可以執行 yum install lsof 安裝,debian可以執行 apt get install lsof 安裝。lsof filename 顯示開啟指定檔案的所有程序 lsof a 表示兩個引數都必須滿...

Linux之lsof的用法

lsof list open files 是乙個列出當前系統開啟檔案的工具。在linux環境下,任何事物都以檔案的形式存在,通過檔案不僅僅可以訪問常規資料,還可以訪問網路連線和硬體。所以如傳輸控制協議 tcp 和使用者資料報協議 udp 套接字等,系統在後台都為該應用程式分配了乙個檔案描述符,無論這...

io相關 lsof用法實驗測試

1 查詢誰在使用檔案系統 sudo mount o loop centos 6.2 x86 64 bin 1.iso mnt dir tail f mnt dir trans.tbl sudo umount mnt dir lsof mnt dir kill 9 pid sudo umount mn...