是否可以使用“lsof -nP -i4UDP”输出完整的命令名称?

是否可以使用“lsof -nP -i4UDP”输出完整的命令名称?

是否可以使用 输出完整的命令名称lsof -nP -i4UDP

我一直在手册中寻找合适的选项,例如-V(见下文),但它不会产生全COMMAND名,即systemd-resolve显示为systemd-r

$ sudo lsof -V -nP -i4UDP
COMMAND    PID            USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
avahi-dae  437           avahi   12u  IPv4  12982      0t0  UDP *:5353 
avahi-dae  437           avahi   14u  IPv4  12984      0t0  UDP *:45006 
cups-brow  449            root    7u  IPv4  12149      0t0  UDP *:631 
systemd-r  485 systemd-resolve   12u  IPv4  14694      0t0  UDP 127.0.0.53:53 
systemd-r  485 systemd-resolve   13u  IPv4  14695      0t0  UDP *:5355 
dhclient   629            root    6u  IPv4  14985      0t0  UDP *:68 
minissdpd 1186            root    4u  IPv4  19639      0t0  UDP *:1900 

答案1

man lsof

+c w     defines the maximum number of initial characters of the name,
         supplied by the UNIX dialect, of the UNIX command associated with a
         process to be printed in the COMMAND  column.  (The lsof default is nine.)

         Note  that  many UNIX dialects do not supply all command name characters
         to lsof in the files and structures from which lsof obtains command name.
         Often  dialects limit the number  of characters supplied in those sources.
         For example, Linux 2.4.27 and Solaris 9 both limit command name length to
         16 characters.

         If w is zero ('0'), all command characters supplied to lsof by the UNIX
         dialect will be printed.

         If  w  is  less  than the length of the column title, ``COMMAND'', it will
         be raised to that length.

鉴于此,您可以添加+c0以获得所有可用的内容:

$ sudo lsof -V -nP -i4UDP +c0
COMMAND         PID            USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
systemd-resolve 176 systemd-resolve   11u  IPv4  11204      0t0  UDP *:5355

相关内容