lsof(list open files)是一个列出当前系统打开文件的工具,我通常使用它来查看网络端口占用,因为在Linux下所有事物都是以文件的形式存在。
root@node5:~# lsof | head -10
COMMAND PID TID USER FD TYPE DEVICE SIZE/OFF NODE NAME
systemd 1 root cwd DIR 254,0 4096 2 /
systemd 1 root rtd DIR 254,0 4096 2 /
systemd 1 root txt REG 254,0 1120992 2884146 /lib/systemd/systemd
systemd 1 root mem REG 254,0 19008 2883683 /lib/x86_64-linux-gnu/libuuid.so.1.3.0
systemd 1 root mem REG 254,0 18832 2883613 /lib/x86_64-linux-gnu/libattr.so.1.1.0
systemd 1 root mem REG 254,0 79936 2883655 /lib/x86_64-linux-gnu/libgpg-error.so.0.21.0
systemd 1 root mem REG 254,0 283464 2883666 /lib/x86_64-linux-gnu/libblkid.so.1.1.0
systemd 1 root mem REG 254,0 22944 2883621 /lib/x86_64-linux-gnu/libcap-ng.so.0.0.0
systemd 1 root mem REG 254,0 14640 2883595 /lib/x86_64-linux-gnu/libdl-2.24.so
...