netstat与lsof命令
Netstat 命令
安装
Ubuntu:sudo apt install net-tools
netstat -a
查看所有套接字
netstat -ap
查看所有的套接字与PID
注:
-a, --all display all sockets (default: connected)
-p, --programs display PID/Program name for sockets
netstat -ap | grep 端口号
查看某端口
lsof命令
lsof(list open files)是一个列出当前系统打开文件的工具
lsof 查看端口占用语法格式:
lsof -i:端口号
示例:
➜ $ lsof -i |
问题解决
错误:执行netstat命令报错: command not found: netstat
环境:Ubuntu
解决:sudo apt install net-tools
参考文献
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Axinの博客!
评论