Answers:
正确的语法是:
lsof -a -i4 -i6 -itcp
这将选择IPv4或IPv6的TCP套接字。
看一下两个输出。这是我系统中的样本
lsof -n -itcp | head -4
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
rpcbind 1509 root 8u IPv4 9013 0t0 TCP *:sunrpc (LISTEN)
rpcbind 1509 root 11u IPv6 9016 0t0 TCP *:sunrpc (LISTEN)
rpc.statd 1537 statd 8u IPv4 10059 0t0 TCP *:36035 (LISTEN)
lsof -n | grep TCP | head -4
rpcbind 1509 root 8u IPv4 9013 0t0 TCP *:sunrpc (LISTEN)
rpcbind 1509 root 11u IPv6 9016 0t0 TCP *:sunrpc (LISTEN)
rpc.statd 1537 statd 8u IPv4 10059 0t0 TCP *:36035 (LISTEN)
rpc.statd 1537 statd 10u IPv6 10063 0t0 TCP *:45203 (LISTEN)
快速浏览显示,到目前为止,唯一明显的区别是空白。可以很容易地将其进行比较以找到真正的差异:
lsof -n -itcp | sort >1
lsof -n | grep TCP | sort >2
diff -wu 1 2 | grep '^[+-]'
--- 1 2015-10-13 20:43:12.588658249 +0100
+++ 2 2015-10-13 20:43:18.272678740 +0100
-COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
+dconf 3618 3634 roaima 11u IPv6 12705 0t0 TCP [::1]:45177->[::1]:6010 (ESTABLISHED)
+gdbus 3632 3633 roaima 5u IPv6 14008 0t0 TCP [::1]:45179->[::1]:6010 (ESTABLISHED)
+virt-mana 3618 3636 roaima 11u IPv6 12705 0t0 TCP [::1]:45177->[::1]:6010 (ESTABLISHED)
+virt-mana 3618 3645 roaima 11u IPv6 12705 0t0 TCP [::1]:45177->[::1]:6010 (ESTABLISHED)
根据此输出,我建议我的情况是IPv6流量。您可能想回顾一下自己的情况,但我怀疑情况是一样的。
-a
到AND他们