"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

おすすめ記事