实例

例如: 查看22端口现在运行的情况

# lsof -i :22
COMMAND  PID USER   FD   TYPE DEVICE SIZE NODE NAME
sshd | 1409 root | 3u  IPv6   5678 |    TCP *:ssh (LISTEN)

查看所属root用户进程所打开的文件类型为txt的文件:

# lsof -a -u root -d txt
COMMAND | PID USER  FD |   TYPE DEVICE | SIZE | NODE NAME
init |    1 | root txt |    REG | 3,3   38432 1763452 /sbin/init
mingetty  1632 root txt |    REG | 3,3   14366 1763337 /sbin/mingetty
mingetty  1633 root txt |    REG | 3,3   14366 1763337 /sbin/mingetty
mingetty  1634 root txt |    REG | 3,3   14366 1763337 /sbin/mingetty
mingetty  1635 root txt |    REG | 3,3   14366 1763337 /sbin/mingetty
mingetty  1636 root txt |    REG | 3,3   14366 1763337 /sbin/mingetty
mingetty  1637 root txt |    REG | 3,3   14366 1763337 /sbin/mingetty
kdm |  | 1638 root txt |    REG | 3,3  132548 1428194 /usr/bin/kdm
X |  |   1670 root txt |    REG | 3,3 1716396 1428336 /usr/bin/Xorg
kdm |  | 1671 root txt |    REG | 3,3  132548 1428194 /usr/bin/kdm
startkde  2427 root txt |    REG | 3,3  645408 1544195 /bin/bash
... ...