1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| Options: Defaults in parentheses; comma-separated set (s) items; dash-separated ranges. -?|-h 帮助 -a 指定选项之间为与的关系AND (默认为或OR) -b avoid kernel blocks -c 指定进程名称,例如chrony,或使用^chrony排除指定进程,或者使用正则/SSHD/i,i表示忽略大小写 +c 指定进程名称长度 (默认为9个字符) +d 显示目录及目录下被打开的文件和目录 +D 递归显示目录及目录下被打开的文件和目录 (注意可能如果文件较多,可能会比较慢) -d s select by FD set -K list tasKs (threads) -i 显示网络连接,也可以指定具体格式[46][proto][@host|addr][:svc_list|port_list] -l 显示UID而非用户名 -n 显示IP地址而非主机名 -N 选择NFS文件 -o list file offset -O no overhead *RISKY* -P 显示端口号而非服务名称 -R 显示父进程号PPID -t 只显示PID,可用于批量kill进程 -T disable TCP/TPI info -U select Unix socket -- end option scan, 用于文件名中有-的情况,避免和选项冲突 -F 显示指定列,如-Fpcn0. -F? for help +|-L [l] list (+) suppress (-) link counts < l (0 = all; default = 0) -p 指定或排除PID,如-p 22或-p ^22 -S 指定超时时间,单位秒,最小值为2 (默认15) -T qs TCP/TPI Q,St (s) info -g [s] exclude(^)|select and print process group IDs +|-r [t[m<fmt>]] 指定刷新间隔时间 (默认15); + until no files, - forever. 也可以指定时间分隔符m<fmt>,如-r3m"=== %F-%T ===";时间格式参考date命令 -s p:s 指定tcp或udp连接状态 (p = TCP|UDP) states by name(s),如-stcp:established -u 指定或排除用户名或UID -x [fl] cross over +d|+D File systems or symbolic Links names 指定文件
参数格式说明: 多个参数用逗号,分隔,如22,80,443 排除指定参数用^表示,如^80,^443 指定范围用-表示,如1-1025
# 显示指定列,如-Fpcn0 $ lsof -F? ID field description a access: r = read; w = write; u = read/write c command name d device character code D major/minor device number as 0x<hex> f file descriptor G file flaGs i inode number k link count K task ID (TID) l lock: r/R = read; w/W = write; u = read/write L login name m marker between repeated output n comment, name, Internet addresses o file offset as 0t<dec> or 0x<hex> p process ID (PID) g process group ID (PGID) P protocol name r raw device number as 0x<hex> R paRent PID s file size S stream module and device names t file type T TCP/TPI info u user ID (UID) 0 (zero) use NUL field terminator instead of NL
|